我正在进行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),
]
View.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
我该怎么做才能解决这个问题呢? 谢谢