gpt4 book ai didi

python - Django教程最大深度递归

转载 作者:行者123 更新时间:2023-11-28 21:40:20 29 4
gpt4 key购买 nike

我正在做 django 第一个应用程序教程。当我尝试访问本地主机网页时,出现最大深度递归错误。检查方法不断返回,直到达到最大深度。 urls.py的代码如下:

from django.contrib import admin
from django.conf.urls import include
from django.conf.urls import url
from polls import views

urlpatterns = [
url(r'^$', views.index, name ='index'),
url(r'^polls/', include('polls.urls')),
url(r'^admin/', admin.site.urls),
]

查看.py:

from django.shortcuts import render
from django.http import HttpResponse
def index(request):
return HttpResponse("Hello World. You're at the polls index")

错误代码:

File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/checks/urls.py", line 26, in check_resolver
return check_method()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/urls/resolvers.py", line 255, in check
warnings.extend(check_resolver(pattern))
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/checks/urls.py", line 26, in check_resolver
return check_method()
RecursionError: maximum recursion depth exceeded

我该怎么做才能解决这个问题?谢谢

最佳答案

问题是您将民意测验网址包含在其内部。

polls/urls.py 中删除 url(r'^polls/', include('polls.urls')),

该行应该在您项目的 urls.py 中(默认情况下,该行位于包含 settings.py 的目录中)

您也应该将 url(r'^admin/', admin.site.urls), 移动到您项目的 urls.py 中。

关于python - Django教程最大深度递归,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45695539/

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