------------------error------------------------------
Reverse for 'polls.views.results' with arguments '(2L,)' and keyword
arguments '{}' not found.Request Method: POST
Request URL: http://127.0.0.1:8000/polls/2/vote/
Django Version: 1.5
Exception Type: NoReverseMatch
Exception Value: Reverse for 'polls.views.results' with arguments
'(2L,)' and keyword arguments '{}' not found.
Exception Location: c:\python27\lib\site-packages\django\core
\urlresolvers.py in _reverse_with_prefix, line 394
Python Executable: c:\python27\python.exe
Python Version: 2.7.3
Python Path: ['E:\\Django\\mysite',
 'C:\\WINDOWS\\system32\\python27.zip',
 'c:\\python27\\DLLs',
 'c:\\python27\\lib',
 'c:\\python27\\lib\\plat-win',
 'c:\\python27\\lib\\lib-tk',
 'c:\\python27',
 'c:\\python27\\lib\\site-packages']
Server time: Wed, 13 Jun 2012 15:21:37 +0530



---------------------view.py-----------------------
# -*- coding: cp1252 -*-
# Create your views here.
from django.shortcuts import get_object_or_404, render_to_response
from django.http import HttpResponseRedirect, HttpResponse
from django.core.urlresolvers import reverse
from django.template import RequestContext
from polls.models import Choice, Poll

def index(request):
    latest_poll_list = Poll.objects.all().order_by('-pub_date')[:5]
    output = ', '.join([p.question for p in latest_poll_list])
    return HttpResponse(output)

def detail(request, poll_id):
    p = get_object_or_404(Poll, pk=poll_id)
    return render_to_response('polls/detail.html', {'poll': p},
 
context_instance=RequestContext(request))

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):
        # Redisplay the poll voting form.
        return render_to_response('polls/detail.html', {
                'poll': p,
                'error_message': "You didn’t select a choice.",
        }, context_instance=RequestContext(request))
    else:
        selected_choice.votes += 1
        selected_choice.save()
        # Always return an HttpResponseRedirect after successfully
dealing
        # with POST data. This prevents data from being posted twice
if a
        # user hits the Back button.
        return
HttpResponseRedirect(reverse('polls.views.results',args=(p.id,)))

def results(request, poll_id):
    p = get_object_or_404(Poll, pk=poll_id)
    return render_to_response('polls/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 django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to