Our 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.slug.errors. The latter is displayed in Example 8.12.