在创建博客超链接的时候,django报错:without providing an app_name is not supported. Set the app_name attribute in t

报错信息:

without providing an app_name is not supported. Set the app_name attribute in the included module, or pass a 2-tuple con

具体代码如下:

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


urlpatterns = [
    url('admin/', admin.site.urls),
    url('blog/',include('blog.urls')),
    url('blog2/',include('blog2.urls',namespace='blog2'))
]

include函数包含两个参数,第一个是arg,第二个是namespace,arg应该是一个二元元组,但是代码中给的只是一个blog2.urls,所以代码改成如下样式:

url('blog2/',include(('blog2.urls','blog2'),namespace = 'blog2'))

然后重新runserver,正常运行

发布了3 篇原创文章 · 获赞 0 · 访问量 33

猜你喜欢

转载自blog.csdn.net/G36320/article/details/104901124