Reputation: 91
I am doing the django first app tutorial. When I try access the localhost webpage, I get a maximum depth recursion error. The check method keeps on getting returned until maximum depth. The code is as follows for 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")
The error code:
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
What can I do to remedy this? Thank you
Upvotes: 6
Views: 2815
Reputation: 308909
The problem is that you are including the polls urls inside itself.
Remove url(r'^polls/', include('polls.urls')),
from your polls/urls.py
.
That line should be in your project's urls.py instead (by default, that's the one in the directory that contains settings.py
)
You should move url(r'^admin/', admin.site.urls),
to your project's urls.py
as well.
Upvotes: 10