Alex Rivera | Logout

Django Error u"'polls" is not a registered namespace

Asked 2013-02-15T10:16:06.113
52

Yesterday I was working on my first app using this tutorial. It's a Poll and Choice app. The first page displays the question and when you click on the question it's suppose to display choices which you can vote on them.

I had great people who helped me yesterday and told me to use namespace. I've read the namespace tutorial and tried to apply my knowledge to the scenario but it isn't working so far.

This is my error when I click on the questions which is the first page.

 NoReverseMatch at /polls/5/

 u"'polls" is not a registered namespace

 Request Method:    GET
 Request URL:   http://127.0.0.1:8000/polls/5/
 Django Version:    1.4.3
 Exception Type:    NoReverseMatch
 Exception Value:   

 u"'polls" is not a registered namespace

 Exception Location:    C:\hp\bin\Python\Lib\site-packages\django\template\defaulttags.py in render, line 424
 Python Executable:     C:\hp\bin\Python\python.exe
 Python Version:    2.5.2
 Python Path:   

 ['C:\\djcode\\mysite',
  'C:\\hp\\bin\\Python\\python25.zip',
  'C:\\hp\\bin\\Python\\DLLs',
  'C:\\hp\\bin\\Python\\lib',
  'C:\\hp\\bin\\Python\\lib\\plat-win',
  'C:\\hp\\bin\\Python\\lib\\lib-tk',
  'C:\\hp\\bin\\Python',
  'C:\\hp\\bin\\Python\\lib\\site-packages',
  'C:\\hp\\bin\\Python\\lib\\site-packages\\win32',
  'C:\\hp\\bin\\Python\\lib\\site-packages\\win32\\lib',
  'C:\\hp\\bin\\Python\\lib\\site-packages\\Pythonwin']

 Server time:   Fri, 15 Feb 2013 21:04:10 +1100
 Error during template rendering

 In template C:\djcode\mysite\myapp\templates\myapp\detail.html, error at line 5
 u"'polls" is not a registered namespace
 1  <h1>{{ poll.question }}</h1>
 2  
 3  {% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %}
 4  
 5  {% url 'polls:vote' poll.id %}
 6  {% csrf_token %}
 7  {% for choice in poll.choice_set.all %}
 8  <input type="radio" name="choice" id="choice{{ forloop.counter }}" value="{{ choice.id }}" />
 9  <l
Edit
Report

1 Answer

8

You need to add the following line to the top of the detail.html:

{% load url from future %}

(Notice you've already used this line in the index.html in order to use the polls namespace)

answered 2013-02-28T19:59:30.243

Your Answer