path_urls.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. from django.urls import include, path, re_path
  2. from . import views
  3. urlpatterns = [
  4. path("articles/2003/", views.empty_view, name="articles-2003"),
  5. path("articles/<int:year>/", views.empty_view, name="articles-year"),
  6. path(
  7. "articles/<int:year>/<int:month>/", views.empty_view, name="articles-year-month"
  8. ),
  9. path(
  10. "articles/<int:year>/<int:month>/<int:day>/",
  11. views.empty_view,
  12. name="articles-year-month-day",
  13. ),
  14. path("books/2007/", views.empty_view, {"extra": True}, name="books-2007"),
  15. path(
  16. "books/<int:year>/<int:month>/<int:day>/",
  17. views.empty_view,
  18. {"extra": True},
  19. name="books-year-month-day",
  20. ),
  21. path("users/", views.empty_view, name="users"),
  22. path("users/<id>/", views.empty_view, name="user-with-id"),
  23. path("included_urls/", include("urlpatterns.included_urls")),
  24. re_path(r"^regex/(?P<pk>[0-9]+)/$", views.empty_view, name="regex"),
  25. re_path(
  26. r"^regex_optional/(?P<arg1>\d+)/(?:(?P<arg2>\d+)/)?",
  27. views.empty_view,
  28. name="regex_optional",
  29. ),
  30. re_path(
  31. r"^regex_only_optional/(?:(?P<arg1>\d+)/)?",
  32. views.empty_view,
  33. name="regex_only_optional",
  34. ),
  35. path("", include("urlpatterns.more_urls"), {"sub-extra": False}),
  36. path("<lang>/<path:url>/", views.empty_view, name="lang-and-path"),
  37. ]