{% regroup class.list|dictsort:"verbose_name" by verbose_name as classes %}
{% for class in classes %}
    {% if class.grouper %}
        <tr>
            <th colspan="2" style="padding-left: 40px;">{% filter capfirst %}{{ class.grouper }}{% endfilter %}</th>
        </tr>
    {% endif %}
    {% for field in class.list %}
        {% if field.errors %}
        <tr class="error">
            <td colspan="2">{{ field.errors }}</td>
        </tr>
        {% endif %}
        <tr{% if field.errors %} class="error"{% endif %}>
            <td>
                {{ field.label_tag }}
                {% if field.help_text %}
                    <p class="help">{{ field.help_text|escape }}</p>
                {% endif %}
            </td>
            <td>{{ field }}</td>
        </tr>
    {% endfor %}
{% endfor %}
