Django 2:项目根URL命名空间不起作用

问题描述 投票:1回答:1

我在项目根qazxsw poi中有以下url模式:

urls.py

但django抱怨以下消息:

from django.contrib import admin
from django.urls import path, include


urlpatterns = [
    path('admin/', admin.site.urls),
    path('main/', include('main.urls', namespace='main')),
]

根据Django的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. ,'main'的模式应该是正确的。有什么问题?

django url
1个回答
4
投票

您需要将documentation添加到main.urls文件中。请参阅示例和说明app_name = 'main'

© www.soinside.com 2019 - 2024. All rights reserved.