Hello,
I am still working on the Django 1.0 tutorial (http://
docs.djangoproject.com/en/1.0/intro/tutorial04/) and
got the following error after voting on my poll ( which simply makes a
call to the Django reverse function which is supposed to give control
to my results function in polls.views).
The error is the following:
NoReverseMatch at /polls/1/vote/
Reverse for 'mysite.polls.vews.results' with arguments '(1,)' and
keyword arguments '{}' not found.
and my views.py is the following:
from mysite.polls.models import Choice, Poll
from django.shortcuts import get_object_or_404, render_to_response
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect
# ...
def vote(request, poll_id):
p = get_object_or_404(Poll, pk=poll_id)
try:
selected_choice = p.choice_set.get(pk=request.POST['choice'])
except (KeyError, Choice.DoesNotExist):
return render_to_response('detail.html', {
'poll': p,
'error_message': "You didnt select a choice.",
})
else:
selected_choice.votes += 1
selected_choice.save()
return HttpResponseRedirect(reverse
('mysite.polls.vews.results', args=(p.id,)))
def results(request, poll_id):
p = get_object_or_404(Poll, pk=poll_id)
return render_to_response('results.html', {'poll': p})
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---