8.2.1 Using Template Variables to Make the TagForm Template Dynamic

The HTML form we manually coded in our template is exactly what we want users to see when we present an unbound TagForm. However, our code makes us unable to present a bound form with errors or any kind of dynamic content. What’s more, our code is in direct violation of DRY, as any change to TagForm will result in a change to our template.

In the following sections, we will see how to use template variables to replace the current HTML version. This change is mandatory, not only because of our desired adherence to DRY but also because our current form is terrible in terms of usability. Consider that our inability to output form errors, meant to prompt the user into action, is ...

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.