Code

Opened 6 years ago

Closed 6 years ago

#6887 closed (invalid)

fixing vote function in mysite/polls/views.py 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:

Description

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

Is

{{{ def vote(request, poll_id):

p = get_object_or_404(Poll, pk=poll_id)
try:

... }}}

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})
try:

... }}}

Attachments (0)

Change History (1)

comment:1 Changed 6 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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.