Specifying a namespace in include() without providing an app_name(Django)
当我们在项目目录下的urls.py中使用include方法,使用命名空间namespce,却没有指定app的名称,就会出现上述错误。
解决方法:
方法1:在project/urls.py中修改
from django.urls import path,include
from app import urls as app_url
urlpatterns = [
path('', include((common_url,'app01'), namespace='app01')),
]
方法2:在app/urls.py中修改
from django.urls import path
from .views import index
app_name='app01'
urlpatterns = [
path('',index,name='index'),
]