8.7 Putting It All Together
Django supplies a huge amount of flexibility when outputting a form in a template. It is possible to customize the output of bound form data, the form widgets, errors in the form, and any associated data (such as help_text in the model if the form is a ModelForm). This can be quite overwhelming, however. The simplest way to start is to use form.as_p, making sure to write the HTML form tag, submit button, and CSRF token out manually, and then customize as needed.
When building an HTML form in a template, developers must declare the actual HTML form tag, which details the webpage the data will be sent to (action) and how that information is being sent (method). We further need to supply a csrf_token template tag, so ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access