Esempio n. 1
0
def vote(request, poll_key):
    try:
        p = Poll.get_by_id(int(poll_key))
    except:
        raise Http404
    try:
        selected_choice = Choice.get_by_id(int(request.POST['choice']),
                                            parent=p.key)
        selected_choice.votes += 1
        selected_choice.put()
        return HttpResponseRedirect(reverse('polls.views.results', args=(p.key.id(),)))
    except:
        raise Http404