解决django.core.exceptions.ImproperlyConfigured: Specifying a namespace in include() without providing

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.
不支持在include()中指定命名空间而不提供APP名。在包含的模块中设置app名,或者传递包含模式列表和app_name的元组。
出错代码块:

urlpatterns = [
    url('admin/', admin.site.urls),
    url(r"^book/",include("book.urls",namespace="book"))
]

解决:

urlpatterns = [
    url('admin/', admin.site.urls),
    url(r"^book/",include(("book.urls","book"),namespace="book"))
]

你可能感兴趣的:(python,django)