bling123 发表于 2021-2-5 11:24:43

django报错The included URLconf does not appear to have any patterns in it.

django.core.exceptions.ImproperlyConfigured: The included URLconf 'testDjango.urls' does not appear to have any patterns in it. If you see valid patterns in the file then the issue is probably caused by a circular import.
工程架构:


setting.py中配置

主程序testDjango/testDjango/urls.py中路由配置:

应用testDjango/App/urls.py中路由配置:

views.py内容:


执行程序报错:
django.core.exceptions.ImproperlyConfigured: The included URLconf 'testDjango.urls' does not appear to have any patterns in it. If you see valid patterns in the file then the issue is probably caused by a circular import.

qqq911 发表于 2021-2-5 11:41:45

主程序testDjango/testDjango/urls.py中路由配置 ,用path,在加上namespace,试试。

bling123 发表于 2021-2-5 14:24:14

qqq911 发表于 2021-2-5 11:41
主程序testDjango/testDjango/urls.py中路由配置 ,用path,在加上namespace,试试。

试过了,还是同样报错

    path('app/', include('app.urls',namespace='app')),

bling123 发表于 2021-2-5 16:09:40

问题已经解决,是我之前不小心将主程序testDjango/testDjango/urls.py,这个urls.py手工删除掉了,然后自己又手工建了这个文件,后来我重新将整个项目删除掉,重新创建django项目,就好了,具体不清楚什么原因。

litingting0214 发表于 2021-2-5 16:47:08

解决了就好 赞

郭小贱 发表于 2021-2-5 17:02:57

学习了。

jingzizx 发表于 2021-2-7 07:24:53

;P
页: [1]
查看完整版本: django报错The included URLconf does not appear to have any patterns in it.