Opened 11 years ago

Closed 11 years ago

#10914 closed (duplicate)

The chapter "Write a simple form" produces code with bad Choice.DoesNotExist handling

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


If you code the “polls/detail.html” template and the "mysite/polls/" vote() function as in the tutorial, after voting without choosing an option, a DoesNotExist exception is raised and the poll voting form is redisplayed with a "You didn't select a choice." message. The problem is that you cannot try to vote a second time, because the redisplayed page is not "polls/1/" but "polls/1/vote/".

To reproduce:

  • Complete tutorial 1 to 4 (for Django 1.0.2)
  • go to "http://localhost:8000/polls/1/"
  • Click vote without selecting a Choice
  • The page will be polls/1/vote/, not polls/1/ again
  • Try to vote (or not, just click again vote)

It fails because it tries to access "polls/1/vote/vote/"

Change History (2)

comment:1 Changed 11 years ago by tobami

A possible solution would be to modify the form in poll_detail.html.

<form action="vote/" method="post">

<form action="/polls/{{ }}/vote/" method="post">

solves the problem, but it strikes me as a bit "hacky".

Is there another, cleaner way to solve it?

comment:2 Changed 11 years ago by Karen Tracey

Resolution: duplicate
Status: newclosed

#10801 already reported this.

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