Django таблица html по модели - Python
Формулировка задачи:
Подскажите как с джанго по модели вывести в темплейт таблицу вида:
Решение задачи: «Django таблица html по модели»
textual
Листинг программы
{% block content %}
<table border="1">
<tr>
<th>SUBDIVISION</th>
<th>SERVICE</th>
<th>PRICE1</th>
<th>PRICE2</th>
<th>PRICE3</th>
<th>PRICE4</th>
<th>PRICE5</th>
</tr>
{% for sbd in subs %}
<tr>
<td {% if sbd.services.count > 1 %} rowspan="{{ sbd.services.count }}" {% endif %}> {{ sbd }}</td>
<td> {{ sbd.services.0 }} </td>
{% for p in sbd.services.0.prices %}
<td> {{ p }} </td>
{% endfor %}
</tr>
{% for service in sbd.services.all|slice:"1:" %}
<tr>
<td> {{ service }} </td>
{% for p in service.prices %}
<td> {{ p }} </td>
{% endfor %}
</tr>
{% endfor %}
{% endfor %}
</table>
{% endblock %}