我已经搜索了所有可以找到的有关此错误的问题并尝试了所有解决方案,但没有一个(保存一个;稍后会详细介绍)对我有用。每次启动我的应用程序时,都会出现以下错误:
django.core.exceptions.ImproperlyConfigured: The included URLconf 'gamerank.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.
我检查了我的文件是否有循环导入,但根本找不到。
This answer 对我有用,但在那之后我无法访问我的任何应用程序(因为我刚刚注释掉了路由),所以这对我来说并不是真正的解决方案。
这是我的一些文件:
投票/urls.py
from django.urls import path
from . import views
app_name = 'voting'
urlpatterns = [
path('', views.index, name="index"),
# auth routes
path("login", views.login_view, name="login"),
path("logout", views.logout_view, name="logout"),
path("register", views.register, name="register")
]
gamerank/urls.py
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('voting.urls')),
]
答案 0 :(得分:0)
原来我试图在会导致循环导入的模块中运行 reverse
。解决方案是按照评论中的建议使用 reverse_lazy
。