#18946: Possible error in vote function
-------------------------------+--------------------
     Reporter:  mr_rjharris@…  |      Owner:  nobody
         Type:  Uncategorized  |     Status:  new
    Component:  Documentation  |    Version:  1.4
     Severity:  Normal         |   Keywords:
 Triage Stage:  Unreviewed     |  Has patch:  0
Easy pickings:  0              |      UI/UX:  0
-------------------------------+--------------------
 {{{
 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.

 I tried to generate an exception by opening a blank page in the browser
 and entering an url such as

 http://localhost:8000/polls/1/vote/

 and received the following response

 NameError at /polls/1/vote/

 global name 'Choice' is not defined.  etc.

 I modified the except line to

 except KeyError:

 and the code worked as expected, opening the url
 http://localhost:8000/polls/1/vote/
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/18946>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" 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 https://groups.google.com/groups/opt_out.


Reply via email to