O'Reilly logo

Django 1.1 Testing and Debugging by Karen M. Tracey

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Handling invalid Survey submissions

We've already coded the view that handles survey submission to re-display the page with errors instead of processing the results, if any errors are found in the submitted forms. On the display side, since we are using the as_p convenience method for displaying the form, it will take care of displaying any errors in the forms. So, we should have no code or template changes to make in order to see what happens when an invalid survey is submitted.

What would make a survey submission invalid? The only likely error case for our QuestionVoteForm is if no answer is chosen. What happens, then, if we attempt to submit a survey with missing answers? If we try it, we see that the result is not ideal:

There are at least two ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required