Reputation: 1376
python manage.py runserver
throws exception. How do I get my launch webpage on localhost?
I have tried Django Slack community group and also tried StackOverflow question regarding "RecursionError" in Django Framework, but the answers are uncertain and confusing.
python3 manage.py runserver Performing system checks...
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x102b926a8>
Traceback (most recent call last):
File "/Users/kuldeep/env/lib/python3.7/site-packages/django/utils/autoreload.py", line 225, in wrapper fn(*args, **kwargs)
File "/Users/kuldeep/env/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run self.check(display_num_errors=True)
File "/Users/kuldeep/env/lib/python3.7/site-packages/django/core/management/base.py", line 379, in check
include_deployment_checks=include_deployment_checks,
File "/Users/kuldeep/env/lib/python3.7/site-packages/django/core/management/base.py", line 366, in _run_checks
return checks.run_checks(**kwargs)
File "/Users/kuldeep/env/lib/python3.7/site-packages/django/core/checks/registry.py", line 71, in run_checks
new_errors = check(app_configs=app_configs)
File "/Users/kuldeep/env/lib/python3.7/site-packages/django/core/checks/urls.py", line 40, in check_url_namespaces_unique
all_namespaces = _load_all_namespaces(resolver)
File "/Users/kuldeep/env/lib/python3.7/site-packages/django/core/checks/urls.py", line 67, in _load_all_namespaces
namespaces.extend(_load_all_namespaces(pattern, current))
File "/Users/kuldeep/env/lib/python3.7/site-packages/django/core/checks/urls.py", line 67, in _load_all_namespaces
namespaces.extend(_load_all_namespaces(pattern, current))
File "/Users/kuldeep/env/lib/python3.7/site-packages/django/core/checks/urls.py", line 67, in _load_all_namespaces
namespaces.extend(_load_all_namespaces(pattern, current))
[Previous line repeated 986 more times]
File "/Users/kuldeep/env/lib/python3.7/site-packages/django/core/checks/urls.py", line 59, in _load_all_namespaces
':'.join(parents + (url.namespace,)) for url in url_patterns
File "/Users/kuldeep/env/lib/python3.7/site-packages/django/core/checks/urls.py", line 60, in <listcomp>
if getattr(url, 'namespace', None) is not None
RecursionError: maximum recursion depth exceeded while calling a Python object
I am expecting the flying rocket which gives me confidence of congratulation message on my localhost.
mysite/urls.py file:
from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path('polls/', include('polls.urls')),
path('admin/', admin.site.urls),
]
polls/urls.py file:
from django.urls import include, path
from django.contrib import admin
from . import views
urlpatterns = [
path('polls/', include ('polls.urls')),
path ('admin/', admin.site.urls),
]
polls/views.py code:
from django.shortcuts import render
# Create your views here.
from django.http import HttpResponse
def index(request):
return HttpResponse("Hello, world. You are at the polls index")
Upvotes: 0
Views: 3769
Reputation: 20702
Look at your polls/urls.py code for urlpatterns
, it's including itself, which causes an endless loop.
Your polls/urls.py should contain the sub-paths specific for the polls app. Since this app has just one view, you probably just want one path:
path('', views.index)
Remember, this is included by my_site/urls.py under the polls/
path, so the full path to get the index
view will be: "/polls/".
You're probably doing the Django tutorial, check you code here
Upvotes: 3