{% load form_helpers %} {% 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 %}
{% if group %}
{{ group }}
{% endif %} {% for name in fields %} {% with field=form|getfield:name %} {% if field and 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 %}
{% render_field form.comments %}
{% endif %} {% else %} {# Render all fields in a single group #}
{% render_form form %}
{% endif %}