2019-12-21 18:22:18 +00:00
|
|
|
from django.urls import path, re_path, register_converter
|
2019-12-21 18:11:43 +00:00
|
|
|
|
2019-12-21 18:22:18 +00:00
|
|
|
from . import converters, views
|
|
|
|
|
2022-02-03 19:24:19 +00:00
|
|
|
register_converter(converters.DynamicConverter, "to_url_value_error")
|
2019-12-21 18:11:43 +00:00
|
|
|
|
|
|
|
urlpatterns = [
|
|
|
|
# Different number of arguments.
|
2022-02-03 19:24:19 +00:00
|
|
|
path("number_of_args/0/", views.empty_view, name="number_of_args"),
|
|
|
|
path("number_of_args/1/<value>/", views.empty_view, name="number_of_args"),
|
2019-12-21 18:11:43 +00:00
|
|
|
# Different names of the keyword arguments.
|
2022-02-03 19:24:19 +00:00
|
|
|
path("kwargs_names/a/<a>/", views.empty_view, name="kwargs_names"),
|
|
|
|
path("kwargs_names/b/<b>/", views.empty_view, name="kwargs_names"),
|
2019-12-21 18:11:43 +00:00
|
|
|
# Different path converters.
|
2022-02-03 19:24:19 +00:00
|
|
|
path("converter/path/<path:value>/", views.empty_view, name="converter"),
|
|
|
|
path("converter/str/<str:value>/", views.empty_view, name="converter"),
|
|
|
|
path("converter/slug/<slug:value>/", views.empty_view, name="converter"),
|
|
|
|
path("converter/int/<int:value>/", views.empty_view, name="converter"),
|
|
|
|
path("converter/uuid/<uuid:value>/", views.empty_view, name="converter"),
|
2019-12-21 18:11:43 +00:00
|
|
|
# Different regular expressions.
|
2022-02-03 19:24:19 +00:00
|
|
|
re_path(r"^regex/uppercase/([A-Z]+)/", views.empty_view, name="regex"),
|
|
|
|
re_path(r"^regex/lowercase/([a-z]+)/", views.empty_view, name="regex"),
|
2019-12-21 18:22:18 +00:00
|
|
|
# converter.to_url() raises ValueError (no match).
|
|
|
|
path(
|
2022-02-03 19:24:19 +00:00
|
|
|
"converter_to_url/int/<value>/",
|
2019-12-21 18:22:18 +00:00
|
|
|
views.empty_view,
|
2022-02-03 19:24:19 +00:00
|
|
|
name="converter_to_url",
|
2019-12-21 18:22:18 +00:00
|
|
|
),
|
|
|
|
path(
|
2022-02-03 19:24:19 +00:00
|
|
|
"converter_to_url/tiny_int/<to_url_value_error:value>/",
|
2019-12-21 18:22:18 +00:00
|
|
|
views.empty_view,
|
2022-02-03 19:24:19 +00:00
|
|
|
name="converter_to_url",
|
2019-12-21 18:22:18 +00:00
|
|
|
),
|
2019-12-21 18:11:43 +00:00
|
|
|
]
|