jeck猫
文件说_view 参数是一个视图函数或 as_view() 对于基于类的视图的结果。它也可以是 django.urls.include()。如果您查看源代码,def _path(route, view, kwargs=None, name=None, Pattern=None): if isinstance(view, (list, tuple)): # For include(...) processing. pattern = Pattern(route, is_endpoint=False) urlconf_module, app_name, namespace = view return URLResolver( pattern, urlconf_module, kwargs, app_name=app_name, namespace=namespace, ) elif callable(view): pattern = Pattern(route, name=name, is_endpoint=True) return URLPattern(pattern, view, kwargs, name) else: raise TypeError('view must be a callable or a list/tuple in the case of include().')您会看到它只是检查参数类型并根据它是元组还是可调用对象执行不同的操作。