You cannot use the module operator in Django template tags, but it would be enough to write a filter to do this. Something like this should work:
@register.filter def modulo(num, val): return num % val
And then:
{% ifequal forloop.counter0|modulo:4 0 %}
Instead, you can do something like this:
@register.filter def modulo(num, val): return num % val == 0
And then:
{% if forloop.counter0|modulo:4 %}
Or you can use the cycle tag:
<div class="post width1 height2 column {% cycle 'first' '' '' '' %}">
mipadi Dec 13 '11 at 18:36 2011-12-13 18:36
source share