你可能 以path("",include("xxx.urls"),namespace="xxx")的方式定义路由了
django规定若设置namespace且include的arg参数为字符串或者元组长度不足2的时候,运行项目则会发生以下错误:
line 20, in <module>
path('index', include(("index.urls" ), namespace="index")),
File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/urls/conf.py", line 39, in include
'Specifying a namespace in include() without providing an app_name '
django.core.exceptions.ImproperlyConfigured: Specifying a namespace in include() without providing an app_name is not supported. Set the app_name attribute in the included module, or pass a 2-tuple containing the list of patterns and app_name instead.
解决方案:
1.传include第二个参数,一般为项目目录名称如:
path('index', include(("index.urls", "index"), namespace="index")),