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 ...

Get Django Unleashed 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.