I'm trying to use directeur's Django-sorting in a modelformset. My template code looks like this:
{% load sorting_tags %}
<table style="text-align: left;" border="1" cellpadding="5" cellspacing="0">
{% autosort formset.forms %}
{% for form in formset.forms %}
{% if forloop.first %}
<tr>
{% for field in form %}
{% if not field.is_hidden %}
<th>{% anchor field.label field.label %}</th>
{% else %}
<th></th>
{% endif %}
{% endfor %}
</tr>
{% endif %}
<tr>
{% for field in form %}
<td>{{ field }}{{ field.errors }}</td>
{% endfor %}
</tr>
{% endfor %}
</table>
I am having 2 problems with this. The most significant is that the sorting doesn't work because formset.forms does not have an order_by attribute. The second problem is that the "anchor" tag apparently doesn't accept variables for the 2nd parameter. The column headings are literally "field.label" instead of the value of field.label.
I'm not particularly wedded to this auto-sort solution, but I would dearly like to be able to sort (and paginate) this.