Reputation: 2612
I'm trying to use Django's template language to do some calculations:
{% if forloop.counter|divisibleby:table.1|length %}
but I want the divisibleby
to take table.1|length
as an argument rather than only table.1
like it seems to do by default. (table.1 is a list
)
Any way to do this besides passing the length from a view?
Upvotes: 0
Views: 1316
Reputation: 13731
You could do something like using the template tag with
{% with table_length=table.1|length %}
{% if forloop.counter|divisibleby:table_length %}
{% endif %}
{% endwith %}
Upvotes: 2