I have a Django model formset, and some fields have hidden inputs.
I am trying to generate the headings from the first item in the formset with formset.visible_fields. This works.
<table>
<tr>
{% for myfield in formset.0.visible_fields %}
<th> {{ myfield.name }}</th>
{% endfor %}
</tr>
{%for form in formset %}
<tr>
{% for field in form %}
<td>{{ field }}</td>
{% endfor %}
</tr>
{% endfor%}
</table>
The problem is that the hidden fields don't get a heading. But when I am iterating through my form fields, the hidden field is still getting wrapped with a tag. So I get a column for every field, but a heading for only the visible fields.
Is there a way to check in advance if my field is hidden? (Or is there a better way to hide the headings / fields?)