[Fixed]-Django 'polls' is not a registered namespace

26👍

I think you forgot to set the namespace when including the polls urls.

In the root urlconf file

Change

url(r'^polls/', include('polls.urls')),

to

url(r'^polls/', include('polls.urls', namespace="polls")),
👤nikora

8👍

Yes, namespace issue for me as well – the above response helped me!

Really important to make sure you are in /polls not /admin/polls when you are inputting your server link on the browser.

Also, this works in path as well.

For mysite/polls/urls – please add the below line of code

app_name = 'polls'

and then also your mysite/mysite/urls should look like below:

from django.contrib import admin
from django.urls import include, path

urlpatterns = [
    path('polls/', include('polls.urls', namespace="polls")),
    path('admin/', admin.site.urls),
]

8👍

you should add app name as like below in polls/urls.py, I had the same issue but solved it by adding this:

app_name = 'polls'

Leave a comment