Opened 8 years ago

Closed 8 years ago

#6887 closed (invalid)

fixing vote function in mysite/polls/ on page 4 of tutorial

Reported by: andy Owned by: nobody
Component: Documentation Version: master
Severity: Keywords: tutorial, vote
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


There is a line of code missing from the vote function defined in mysite/polls/ on page 4 of the Tutorial:


{{{ def vote(request, poll_id):

p = get_object_or_404(Poll, pk=poll_id)

... }}}

Should be

{{{ def vote(request, poll_id):

p = get_object_or_404(Poll, pk=poll_id)
return render_to_response('polls/vote.html', {'poll': p})

... }}}

Change History (1)

comment:1 Changed 8 years ago by Karen Tracey <kmtracey@…>

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

? The formatting is screwy above so maybe I'm missing something, but if vote() had a "return render_to_response" right after looking up the poll the vote would not be recorded. Sending the response is handled in the code after the try: where the vote is set. If an exception is raised when recording the vote, the poll detail page is re-displayed with an error message describing what went wrong. If setting the vote succeeds, a redirect is sent so that the next page displayed is a view of the poll results.

Note: See TracTickets for help on using tickets.
Back to Top