I have a set of Django forms, and some fields have hidden inputs.
I am trying to create headers from the first element in a formset using formset.visible_fields. It 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 hidden fields do not get the header. But when I repeat my form fields, the hidden field is still wrapped with a tag. Therefore, I get a column for each field, but the header is only for visible fields.
Is there a way to check in advance if my field is hidden? (Or is there a better way to hide the headers / fields?)
source share