gpt4 book ai didi

python - Django 说配置不当 : The included URLconf does not appear to have any patterns in it

转载 作者:行者123 更新时间:2023-12-05 07:16:20 24 4
gpt4 key购买 nike

我是 Django 的新手,我在下载的存储库中遇到了问题。我查看了其他答案,但它们似乎不适用于我的项目,或者我没有出现某些人所犯的相同错误。它发送错误

File "C:\Users\Iván\AppData\Local\Programs\Python\Python36\Lib\site-packages\django\urls\resolvers.py", line 596, in url_patterns
raise ImproperlyConfigured(msg.format(name=self.urlconf_name))
django.core.exceptions.ImproperlyConfigured: The included URLconf 'quiniela.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.

我的 quiniela.urls 看起来像这样:

from django.contrib import admin
from django.urls import path
from quinewhats.views import Home
from django.contrib.auth.views import LogoutView
from django.urls import include
from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
path('admin/', admin.site.urls),
path('', Home.as_view()),
path("logout/", LogoutView.as_view(), name="logout"),
path('liga/',include('liga.urls',namespace='liga')),
]

urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

我的 liga.urls 是这样的:

from django.urls import path
from .views import EquiposTableView,EquiposCreateView,EquiposUpdateView,EquiposDeleteView, LigaTableView, LigaCreateView, LigaUpdateView, LigaDeleteView, TorneosTableView,TorneosCreateView,TorneosDeleteView,TorneosUpdateView

app_name='liga'

urlpatterns = [
path('equipos/table/', EquiposTableView.as_view(), name='tabla_equipos'),
path('equipos/create/',EquiposCreateView.as_view(), name='crear_equipos'),
path('equipos/update/<int:pk>/',EquiposUpdateView.as_view(), name='actualizar_equipos'),
path('equipos/delete/<int:pk>/',EquiposDeleteView.as_view(), name='eliminar_equipos'),
path('liga/table/', LigaTableView.as_view(), name='tabla_liga'),
path('liga/create/', LigaCreateView.as_view(), name='crear_liga'),
path('liga/update/<int:pk>/', LigaUpdateView.as_view(), name='actualizar_liga'),
path('liga/delete/<int:pk>/', LigaDeleteView.as_view(), name='eliminar_liga'),

]

我不知道循环导入是什么,但我读到它可能是我的 urls.py 在某种程度上被导入到 views.py 中,但我检查了一下,似乎并非如此。是否有任何其他我正在监督的事情,或者其他一些可能有用的信息?这比我希望的要花更长的时间。

编辑:这是 INSTALLED_APPS:

enter image description here

这是文件结构:

enter image description here

最佳答案

不要在 View 方法中提及括号例如:- EquiposCreateView.as_view() ----> EquiposCreateView.as_view

关于python - Django 说配置不当 : The included URLconf does not appear to have any patterns in it,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59272025/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com