python - Django tutorial maximum depth recursion -
i doing django first app tutorial. when try access localhost webpage, maximum depth recursion error. check method keeps on getting returned until maximum depth. code follows urls.py:
from django.contrib import admin django.conf.urls import include django.conf.urls import url 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 django.http import httpresponse def index(request): return httpresponse("hello world. you're @ 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 remedy this? thank you
the problem including polls urls inside itself.
remove url(r'^polls/', include('polls.urls')), polls/urls.py.
that line should in project's urls.py instead (by default, that's 1 in directory contains settings.py)
you should move url(r'^admin/', admin.site.urls), project's urls.py well.
Comments
Post a Comment