27.3.2 Displaying Create and Update Forms

All of the HTML forms to create or update objects that we created in this book followed a formula. Instead of constantly building these forms, it would have been far simpler for us to create an inclusion tag to display the form with certain parameters.

In our core app, we create the templatetags directory and a display_form.py file. In it, we import our tools and create the template library, as shown in Example 27.27.

Example 27.27: Project Code

core/templatetags/display_form.py in 95d56b7b4f

1   from django.core.exceptions import \ 2       ImproperlyConfigured 3   from django.core.urlresolvers import reverse 4   from django.template import ( 5       Library, TemplateSyntaxError) ...

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.