You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

启动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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.15 18:32:31