Tabela łączone wiersze django template

0
<div class="container">
<table class="table">
<tbody>
{% for obj in object_list %}
    {% with length_ as obj.teacher_set.all|length %}
    {% for teacher  in obj.teacher_set.all %}
	<tr>
<td {% if length_ > 1 %} rowspan={{length_|sub:"{{forloop.counter}}"}} {%endif%} > {{obj}}</td>
	 <td> {{teacher.first_name}} {{teacher.surname}} </td>
        </tr>
{% endwith %}
{% endfor %}
	{% endfor %}
	</tbody>
	</table>

Otrzymuję taki błąd
sub requires 2 arguments, 1 provided
A chcę uzyskać coś takiego:
screenshot-20200920164644.png

0

Stack trace mówi "sub requires 2 arguments, 1 provided". Próbowałeś przeinstalować windowsa? ;)

0

wywalenie length_ i pewne dobre zmiany pomogły

<table class="table">
<tbody>
{% for obj in object_list %}
<tr> {% if obj.teacher_set.all|length > 0 %}
<td {% if obj.teacher_set.all|length > 1 %} rowspan={{obj.teacher_set.all|length}} {%endif%} > {{obj}}</td>
{% endif %}
{% for teacher in obj.teacher_set.all %}
 <td> {{teacher.first_name}} {{teacher.surname}} </td>
</tr>
{% endfor %}
{% endfor %}
</tbody>
</table>

1 użytkowników online, w tym zalogowanych: 0, gości: 1