Django formset tabulated fields (as in InlineTablular)


/ Published in: Other
Save to your folder(s)



Copy this code and paste it in your HTML
  1. {{ formset.non_form_errors }}
  2. <table id="formset" class="form">
  3. {% for form in formset.forms %}
  4. {# TODO: showing form.non_field_errors #}
  5. {% if forloop.first %}
  6. <thead><tr>
  7. {% for field in form.visible_fields %}
  8. <th>{{ field.label|capfirst }}</th>
  9. {% endfor %}
  10. </tr></thead>
  11. {% endif %}
  12. <tr class="{% cycle row1,row2 %}">
  13. {% for field in form.visible_fields %}
  14. <td>
  15. {# Include the hidden fields in the form #}
  16. {% if forloop.first %}
  17. {% for hidden in form.hidden_fields %}
  18. {{ hidden }}
  19. {% endfor %}
  20. {% endif %}
  21. {{ field.errors.as_ul }}
  22. {{ field }}
  23. </td>
  24. {% endfor %}
  25. </tr>
  26. {% endfor %}

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.