November 2015
Beginner to intermediate
840 pages
26h 30m
English
tag_form.htmlOur understanding of displaying forms in templates has focused entirely on minute control of the form. However, we have done so at the cost of the DRY principle. In the following subsection, we significantly shorten the code used to display forms—at the cost of control of our HTML.
One of the key shortcuts Django provides is the ability to call variables directly to provide looping behavior. For example, we are currently looping over form.non_field_errors (form errors not specific to any field), form.name.errors, and form.slug.errors. The latter is displayed in Example 8.12.
Example 8.12: Project Code
Read now
Unlock full access