Problem solved. I missed a step in the tutorial where name spacing in the root URLconf was discussed. I still don't understand it completely but the bottom line is that the line number 4 in the file index.html should be replaced with

<li><a href="{% url 'polls:detail' poll.id %}">{{ poll.question }}</a></li>

On 09/07/2013 11:29 PM, voger wrote:
The previous message was delivered as a garbage due to html formating. I
am sending it again as plain text.


Hi everyone. I am trying to walk through the polls tutorial. I am stuck
at the part 4 after the change of the views from function based to class
based. A search in Google brought plenty results but none of them seems
to be related exactly to this situation or maybe it is over my head to
understand what is going on.
When I visit http://127.0.0.1:8000/polls/ i get

NoReverseMatch at /polls/

Reverse for 'detail' with arguments '(1,)' and keyword arguments '{}'
not found.

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

Reverse for 'detail' with arguments '(1,)' and keyword arguments '{}'
not found.

...

In template
/home/voger/PycharmProjects/mysite/polls/templates/polls/index.html,
error at line 4
Reverse for 'detail' with arguments '(1,)' and keyword arguments '{}'
not found.
1     {% if latest_poll_list %}
2     <ul>
3     {% for poll in latest_poll_list %}
4     <li><a href="{% url 'detail' poll.id %}">{{ poll.question }}</a></li>
5     {% endfor %}
6     </ul>
7     {% else %}
8     <p>No polls are available.</p>
9     {% endif %}

The offending line is line number 4. The classes used are

class IndexView(generic.ListView):
     template_name = 'polls/index.html'
     context_object_name = 'latest_poll_list'

     def get_queryset(self):
         """Return the last five published polls."""
         return Poll.objects.order_by('-pub_date')[:5]

class DetailView(generic.DetailView):
     model = Poll
     template_name = 'polls/detail.html'

and in /polls/urls.py the urls are

urlpatterns = patterns('',
     url(r'^$', views.IndexView.as_view(), name='index'),
     url(r'^(?P<pk>\d+)/$', views.DetailView.as_view(), name='detail'),
     url(r'^(?P<pk>\d+)/results/$', views.ResultsView.as_view(),
name='results'),
     url(r'^(?P<poll_id>\d+)/vote/$', views.vote, name='vote'),
)

Can someone please explain what is wrong?


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to