본문 바로가기

Python_WEB/Django_Tutorial

[Django]'polls" is not a registered namespace Error

Django Tutorial 도중 발생한 namespace Error가 있다.

이를 해결 하기 위한 방법이 있다.

 

Error Massge>

NoReverseMatch at

 'polls" is not a registered namespace

 Request Method:
 Request URL:
 Django Version:
 Exception Type:
 Exception Value:   

 'polls" is not a registered namespace

 Exception Location:
 Python Executable:
 Python Version:
 Python Path:   


 Server time:
 Error during template rendering

 In template , error at line 5
 'polls" is not a registered namespace

 

Fix>

polls\urls.py 와 mysite\urls.py 를 수정한다.

'''
polls\urls.py
'''
from django.urls import path
from . import views

app_name = 'polls'

urlpatterns = [
    path('', views.IndexView.as_view(), name='index'),
    path('<int:pk>/', views.DetailView.as_view(), name='detail'),
    path('<int:pk>/results/', views.ResultsView.as_view(), name='results'),
    path('<int:question_id>/vote/', views.vote, name='vote'),
]

 

'''
mysite\urls.py
'''
from django.contrib import admin
from django.urls import include, path

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