How forms work

Forms can be tricky to understand because interacting with them takes more than one request-response cycle. In the simplest scenario, you need to present an empty form, which the user then fills in correctly and submits. Conversely, they might enter some invalid data, in which case the form needs to be resubmitted until the entire form is valid.

From this scenario, we can see that a form can be one of several states, changing between them:

  • Empty form (unfilled form): This form is called an unbound form in Django
  • Filled form: This form is called a bound form in Django
  • Submitted form with errors: This form is called a bound form but not a valid form
  • Submitted form without errors: This form is called a bound and valid form

Get Django Design Patterns and Best Practices - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.