{% extends 'base/layout.html' %} {% load form_helpers %} {% load helpers %} {% comment %} Blocks: form: Content within the
element buttons: Form submission buttons Context: object: Python instance of the object being edited form: The edit form return_url: The URL to which the user is redirected after submitting the form {% endcomment %} {% block title %} {% if object.pk %}Editing {{ object|meta:"verbose_name" }} {{ object }}{% else %}Add a new {{ object|meta:"verbose_name" }}{% endif %} {% endblock title %} {% block tabs %} {% endblock tabs %} {% block content-wrapper %}
{# Link to model documentation #} {% if object and settings.DOCS_ROOT %} {% endif %} {% csrf_token %} {% block form %} {% if form.fieldsets %} {# Render hidden fields #} {% for field in form.hidden_fields %} {{ field }} {% endfor %} {# Render grouped fields according to Form #} {% for group, fields in form.fieldsets %}
{{ group }}
{% for name in fields %} {% with field=form|getfield:name %} {% if not field.field.widget.is_hidden %} {% render_field field %} {% endif %} {% endwith %} {% endfor %}
{% endfor %} {% if form.custom_fields %}
Custom Fields
{% render_custom_fields form %}
{% endif %} {% if form.comments %}
Comments
{% render_field form.comments %}
{% endif %} {% else %} {# Render all fields in a single group #}
{% render_form form %}
{% endif %} {% endblock form %}
{% block buttons %} Cancel {% if object.pk %} {% else %} {% endif %} {% endblock buttons %}
{% endblock content-wrapper %}