NoReverseMatch Exception help in Django NoReverseMatch Exception help in Django django django

NoReverseMatch Exception help in Django


Try using:

return HttpResponseRedirect(reverse('poll_results', kwargs={'object_id': p.id}))


Are you sure that's where your error really is? Based on the error message, it sounds like either in a view or in a template you are trying to reverse 'polls/poll_results' (in a template, you may be doing something like {% url polls/poll_results poll.pk %})


I could not find any explanation that fixed the problem, until I ran across this person's abridged Django tutorial: http://tony.abou-assaleh.net/web-development/stripped-down-django-tutorial

It's basically a line in the details template, which should be:

<form action="/polls/{{ poll.id }}/vote/" method="post">

Instead of:

<form action="{% url 'polls.views.vote' poll.id %}" method="post">

I'm not sure why this fixed the issue, but it did for me. I'd love an explanation if anyone has one.