MCPcopy
hub / github.com/django/django / _path

Function _path

django/urls/conf.py:62–92  ·  view source on GitHub ↗
(route, view, kwargs=None, name=None, Pattern=None)

Source from the content-addressed store, hash-verified

60
61
62def _path(route, view, kwargs=None, name=None, Pattern=None):
63 from django.views import View
64
65 if kwargs is not None and not isinstance(kwargs, dict):
66 raise TypeError(
67 f"kwargs argument must be a dict, but got {kwargs.__class__.__name__}."
68 )
69 if isinstance(view, (list, tuple)):
70 # For include(...) processing.
71 pattern = Pattern(route, is_endpoint=False)
72 urlconf_module, app_name, namespace = view
73 return URLResolver(
74 pattern,
75 urlconf_module,
76 kwargs,
77 app_name=app_name,
78 namespace=namespace,
79 )
80 elif callable(view):
81 pattern = Pattern(route, name=name, is_endpoint=True)
82 return URLPattern(pattern, view, kwargs, name)
83 elif isinstance(view, View):
84 view_cls_name = view.__class__.__name__
85 raise TypeError(
86 f"view must be a callable, pass {view_cls_name}.as_view(), not "
87 f"{view_cls_name}()."
88 )
89 else:
90 raise TypeError(
91 "view must be a callable or a list/tuple in the case of include()."
92 )
93
94
95path = partial(_path, Pattern=RoutePattern)

Callers

nothing calls this directly

Calls 3

URLResolverClass · 0.85
callableFunction · 0.85
URLPatternClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…