Path Converters
- synopsis:
path converter keywords in django-boost
Enable path converter keywords
from django_boost.urls import register_boost_converters
register_boost_converters()
Example
from django.urls import path
from django_boost.urls import register_boost_converters
register_boost_converters()
urlpatterns = [
path('bin/<bin:id>', ~~),
path('oct/<oct:id>', ~~),
path('hex/<hex:id>', ~~),
path('float/<float:id>', ~~),
]
Keywords
bin
bin matches regular expression [01]+
This is passed as int type to the python program.
oct
oct match [0-7]+
This is passed as int type to the python program.
hex
hex match [0-9a-fA-F]+
This is passed as int type to the python program.
bin_str
Basically the same as bin.
The difference is that it is passed to the Python program as str
oct_str
Basically the same as oct.
The difference is that it is passed to the Python program as str
hex_str
Basically the same as hex.
The difference is that it is passed to the Python program as str
float
float matches [0-9]+([.][0-9]+)? (alias of non_negative_float).
This is passed as float type to the python program.
date
date matches dates that consider leap years like 'Y/m/d'
This is passed as datetime.datetime type to python program.
signed_int
signed_int matches -?[0-9]+ (any integer, including negatives).
This is passed as int type to the python program.
positive_int
positive_int matches integers greater than 0.
This is passed as int type to the python program.
negative_int
negative_int matches integers less than 0.
This is passed as int type to the python program.
non_negative_int
non_negative_int matches integers greater than or equal to 0.
This is passed as int type to the python program.
non_positive_int
non_positive_int matches integers less than or equal to 0.
This is passed as int type to the python program.
non_zero_int
non_zero_int matches non-zero integers.
This is passed as int type to the python program.
decimal
decimal matches [0-9]+([.][0-9]+)? (alias of non_negative_decimal).
This is passed as decimal.Decimal type to the python program.
signed_decimal
signed_decimal matches any decimal number, including negatives.
This is passed as decimal.Decimal type to the python program.
positive_decimal
positive_decimal matches decimals greater than 0.
This is passed as decimal.Decimal type to the python program.
negative_decimal
negative_decimal matches decimals less than 0.
This is passed as decimal.Decimal type to the python program.
non_negative_decimal
non_negative_decimal matches decimals greater than or equal to 0.
This is passed as decimal.Decimal type to the python program.
non_positive_decimal
non_positive_decimal matches decimals less than or equal to 0.
This is passed as decimal.Decimal type to the python program.
non_zero_decimal
non_zero_decimal matches non-zero decimals.
This is passed as decimal.Decimal type to the python program.
signed_float
signed_float matches any decimal-notation float, including negatives.
This is passed as float type to the python program.
positive_float
positive_float matches floats greater than 0.
This is passed as float type to the python program.
negative_float
negative_float matches floats less than 0.
This is passed as float type to the python program.
non_negative_float
non_negative_float matches floats greater than or equal to 0.
This is passed as float type to the python program.
non_positive_float
non_positive_float matches floats less than or equal to 0.
This is passed as float type to the python program.
non_zero_float
non_zero_float matches non-zero floats.
This is passed as float type to the python program.