table_with_form.html 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. {% extends "asuzr/totals_table.html" %}
  2. {% load django_tables2 %}
  3. {% load i18n %}
  4. {% block table.tbody %}
  5. <tbody>
  6. {% for row in table.page.object_list|default:table.rows %} {# support pagination #}
  7. {% block table.tbody.row %}
  8. <tr class="{{ forloop.counter|divisibleby:2|yesno:"even,odd" }}"> {# avoid cycle for Django 1.2-1.6 compatibility #}
  9. {% for column, cell in row.items %}
  10. <td {{ column.attrs.td.as_html }}>{% if column.localize == None %}{{ cell }}{% else %}{% if column.localize %}{{ cell|localize }}{% else %}{{ cell|unlocalize }}{% endif %}{% endif %}</td>
  11. {% endfor %}
  12. </tr>
  13. {% endblock table.tbody.row %}
  14. {% empty %}
  15. {% if table.empty_text %}
  16. {% block table.tbody.empty_text %}
  17. <tr><td colspan="{{ table.columns|length }}">{{ table.empty_text }}</td></tr>
  18. {% endblock table.tbody.empty_text %}
  19. {% endif %}
  20. {% endfor %}
  21. {% if add_form %}
  22. {% if params %}
  23. <form action="{% url form_action params %}" method="POST" >
  24. {% else %}
  25. <form action="{% url form_action %}" method="POST" >
  26. {% endif %}
  27. {% csrf_token %}
  28. <tr>
  29. {% for field in add_form %}
  30. <td>{{field}}</td>
  31. {% endfor %}
  32. </tr>
  33. <tr>
  34. <td class="align-right" colspan="{{ add_form.fields|length }}"><input type="submit" value="{{ add_form.submit_text }}"></td>
  35. </tr>
  36. </form>
  37. {% endif %}
  38. </tbody>
  39. {% endblock table.tbody %}