Loading docs/topics/forms/index.txt +24 −20 Original line number Diff line number Diff line Loading @@ -104,25 +104,29 @@ The standard pattern for processing a form in a view looks like this: }) There are three code paths here: 1. If the form has not been submitted, an unbound instance of ContactForm is created and passed to the template. 2. If the form has been submitted, a bound instance of the form is created using ``request.POST``. If the submitted data is valid, it is processed and the user is re-directed to a "thanks" page. 3. If the form has been submitted but is invalid, the bound form instance is passed on to the template. The distinction between **bound** and **unbound** forms is important. An unbound form does not have any data associated with it; when rendered to the user, it will be empty or will contain default values. A bound form does have submitted data, and hence can be used to tell if that data is valid. If an invalid bound form is rendered it can include inline error messages telling the user where they went wrong. See :ref:`ref-forms-api-bound-unbound` for further information on the differences between bound and unbound forms. There are three possible code paths here: +------------------+---------------+-----------------------------------------+ | Form submitted? | Data? | What occurs | +==================+===============+=========================================+ | Unsubmitted | None yet | Template gets passed unbound instance | | | | of ContactForm. | +------------------+---------------+-----------------------------------------+ | Submitted | Invalid data | Template gets passed bound instance | | | | of ContactForm. | +------------------+---------------+-----------------------------------------+ | Submitted | Valid data | Valid data is processed. Redirect to a | | | | "thanks" page. | +------------------+---------------+-----------------------------------------+ The distinction between :ref:`ref-forms-api-bound-unbound` is important: * An unbound form has no data associated with it. When rendered to the user, it will be empty or will contain default values. * A bound form has submitted data, and hence can be used to tell if that data is valid. If an invalid bound form is rendered, it can include inline error messages telling the user what data to correct. Handling file uploads with a form --------------------------------- Loading Loading
docs/topics/forms/index.txt +24 −20 Original line number Diff line number Diff line Loading @@ -104,25 +104,29 @@ The standard pattern for processing a form in a view looks like this: }) There are three code paths here: 1. If the form has not been submitted, an unbound instance of ContactForm is created and passed to the template. 2. If the form has been submitted, a bound instance of the form is created using ``request.POST``. If the submitted data is valid, it is processed and the user is re-directed to a "thanks" page. 3. If the form has been submitted but is invalid, the bound form instance is passed on to the template. The distinction between **bound** and **unbound** forms is important. An unbound form does not have any data associated with it; when rendered to the user, it will be empty or will contain default values. A bound form does have submitted data, and hence can be used to tell if that data is valid. If an invalid bound form is rendered it can include inline error messages telling the user where they went wrong. See :ref:`ref-forms-api-bound-unbound` for further information on the differences between bound and unbound forms. There are three possible code paths here: +------------------+---------------+-----------------------------------------+ | Form submitted? | Data? | What occurs | +==================+===============+=========================================+ | Unsubmitted | None yet | Template gets passed unbound instance | | | | of ContactForm. | +------------------+---------------+-----------------------------------------+ | Submitted | Invalid data | Template gets passed bound instance | | | | of ContactForm. | +------------------+---------------+-----------------------------------------+ | Submitted | Valid data | Valid data is processed. Redirect to a | | | | "thanks" page. | +------------------+---------------+-----------------------------------------+ The distinction between :ref:`ref-forms-api-bound-unbound` is important: * An unbound form has no data associated with it. When rendered to the user, it will be empty or will contain default values. * A bound form has submitted data, and hence can be used to tell if that data is valid. If an invalid bound form is rendered, it can include inline error messages telling the user what data to correct. Handling file uploads with a form --------------------------------- Loading