[Answer]-Special counter for loop in django

1👍

You can use the divisibleby filter:

{% for skill in person.skills.all %}
    {% if forloop.counter|divisibleby:"5" %}
        <div style="page-break-after:always"></div>
    {% endif %}
{% endfor %}

That will add a page break at every row that is divisible by 5 (ie. 5, 10, 15, etc).

👤Selcuk

Leave a comment