I want to set a auto_increment variable for some judge,but I found
forloop.counter
can't be use like this
<ul class="listcont2">
{% for item in lists%}
{%if forloop.counter%6==0 && forloop.counter<12 %}
<li><a ><img /></a></li>
</ul>
<ul class="listcont2">
{%else%}
<li><a ><img /></a></li>
{%endif%}
{%endfor%}
</ul>
Is there anyway to set a custom auto_increment variable ?
答案 0 :(得分:2)
You can use divisibleby
instead of the modulus, and and
instead of &&
:
{% if forloop.counter|divisibleby:"6" and forloop.counter < 12 %}