启动Django服务器时出现URL配置错误求助
Django启动服务器URL配置报错记录
报错信息
Exception in thread django-main-thread: Traceback (most recent call last): File "C:\Users\theta\AppData\Local\Programs\Python\Python39\lib\site-packages\django\urls\resolvers.py", line 717, in url_patterns iter(patterns) TypeError: 'module' object is not iterable django.core.exceptions.ImproperlyConfigured: The included URLconf '<module 'app_advertisements' from ' C:\\Users\\theta\\PycharmProjects\\advertisements\\app_advertisements\\__init__.py' >' does not appear to have any patterns in it. If you see the 'urlpatterns' variable with valid patterns in the file then the issue is probably caused by a circular import.
项目根目录urls.py代码
from django.contrib import admin from django.urls import path, include urlpatterns = [ path('admin/', admin.site.urls), path('', include('app_advertisements')), ]
应用app_advertisements下的urls.py代码
from django.urls import path from .views import index urlpatterns = [ path('user/', index), ]
后续补充
新建项目并复制原有代码后,服务器可正常运行,暂未明确原报错原因。
内容的提问来源于stack exchange,提问作者Taimen
相关产品推荐
相关产品推荐

