1. from django.urls import include, path, re_path
    
  2. 
    
  3. from . import views
    
  4. from .utils import URLObject
    
  5. 
    
  6. testobj1 = URLObject("testapp", "test-ns1")
    
  7. testobj2 = URLObject("testapp", "test-ns2")
    
  8. default_testobj = URLObject("testapp", "testapp")
    
  9. 
    
  10. otherobj1 = URLObject("nodefault", "other-ns1")
    
  11. otherobj2 = URLObject("nodefault", "other-ns2")
    
  12. 
    
  13. newappobj1 = URLObject("newapp")
    
  14. 
    
  15. app_name = "namespace_urls"
    
  16. urlpatterns = [
    
  17.     path("normal/", views.empty_view, name="normal-view"),
    
  18.     re_path(
    
  19.         r"^normal/(?P<arg1>[0-9]+)/(?P<arg2>[0-9]+)/$",
    
  20.         views.empty_view,
    
  21.         name="normal-view",
    
  22.     ),
    
  23.     path("resolver_match/", views.pass_resolver_match_view, name="test-resolver-match"),
    
  24.     re_path(r"^\+\\\$\*/$", views.empty_view, name="special-view"),
    
  25.     re_path(
    
  26.         r"^mixed_args/([0-9]+)/(?P<arg2>[0-9]+)/$",
    
  27.         views.empty_view,
    
  28.         {"extra": True},
    
  29.         name="mixed-args",
    
  30.     ),
    
  31.     re_path(r"^no_kwargs/([0-9]+)/([0-9]+)/$", views.empty_view, name="no-kwargs"),
    
  32.     re_path(
    
  33.         r"^view_class/(?P<arg1>[0-9]+)/(?P<arg2>[0-9]+)/$",
    
  34.         views.view_class_instance,
    
  35.         name="view-class",
    
  36.     ),
    
  37.     re_path(r"^unnamed/normal/(?P<arg1>[0-9]+)/(?P<arg2>[0-9]+)/$", views.empty_view),
    
  38.     re_path(
    
  39.         r"^unnamed/view_class/(?P<arg1>[0-9]+)/(?P<arg2>[0-9]+)/$",
    
  40.         views.view_class_instance,
    
  41.     ),
    
  42.     path("test1/", include(*testobj1.urls)),
    
  43.     path("test2/", include(*testobj2.urls)),
    
  44.     path("default/", include(*default_testobj.urls)),
    
  45.     path("other1/", include(*otherobj1.urls)),
    
  46.     re_path(r"^other[246]/", include(*otherobj2.urls)),
    
  47.     path("newapp1/", include(newappobj1.app_urls, "new-ns1")),
    
  48.     path("new-default/", include(newappobj1.app_urls)),
    
  49.     re_path(
    
  50.         r"^app-included[135]/",
    
  51.         include("urlpatterns_reverse.included_app_urls", namespace="app-ns1"),
    
  52.     ),
    
  53.     path(
    
  54.         "app-included2/",
    
  55.         include("urlpatterns_reverse.included_app_urls", namespace="app-ns2"),
    
  56.     ),
    
  57.     re_path(
    
  58.         r"^ns-included[135]/",
    
  59.         include("urlpatterns_reverse.included_namespace_urls", namespace="inc-ns1"),
    
  60.     ),
    
  61.     path(
    
  62.         "ns-included2/",
    
  63.         include("urlpatterns_reverse.included_namespace_urls", namespace="inc-ns2"),
    
  64.     ),
    
  65.     path(
    
  66.         "app-included/",
    
  67.         include("urlpatterns_reverse.included_namespace_urls", "inc-app"),
    
  68.     ),
    
  69.     path("included/", include("urlpatterns_reverse.included_namespace_urls")),
    
  70.     re_path(
    
  71.         r"^inc(?P<outer>[0-9]+)/",
    
  72.         include(
    
  73.             ("urlpatterns_reverse.included_urls", "included_urls"), namespace="inc-ns5"
    
  74.         ),
    
  75.     ),
    
  76.     re_path(
    
  77.         r"^included/([0-9]+)/", include("urlpatterns_reverse.included_namespace_urls")
    
  78.     ),
    
  79.     re_path(
    
  80.         r"^ns-outer/(?P<outer>[0-9]+)/",
    
  81.         include("urlpatterns_reverse.included_namespace_urls", namespace="inc-outer"),
    
  82.     ),
    
  83.     re_path(
    
  84.         r"^\+\\\$\*/",
    
  85.         include("urlpatterns_reverse.namespace_urls", namespace="special"),
    
  86.     ),
    
  87. ]