November 2015
Beginner to intermediate
840 pages
26h 30m
English
Using a loop to iterate over form fields is not actually the shortest way to print a form. Django provides the loop {{ form.as_p }} as a single command, reducing our entire template to that shown in Example 8.22.
Example 8.22: Project Code
organizer/templates/organizer/tag_form.html in 1a77ff0b15
1 {% extends parent_template|default:"organizer/base_organizer.html" %} 2 3 {% block title %} 4 {{ block.super }} - Create Tag 5 {% endblock %} 6 7 {% block content %} 8 <form 9 action="{% url 'organizer_tag_create' %}" 10 method="post"> 11 {% csrf_token %} 12 {{ form.as_p }} 13 <button type="submit"> 14 Create Tag</button> ...
Read now
Unlock full access