{% with forloop.counter|stringformat:"s" as counter %}
{% with row|add:counter as seat_num %}
{% if seat_num not in oc_seats %}
{% endif %}
{{ seat_num }}
{% endwith %}
{% endwith %}
{% endfor %}
{% endfor %}
我最终得到了这个代码
{% for row in 'ABCDEFGH' %}
{% for col in '123456789012345' %}
{% with forloop.counter|stringformat:"s" as counter %} {% with row|add:counter as seat_num %} {% if seat_num not in oc_seats %}
{% endif %} {{ seat_num }} {% endwith %} {% endwith %}