开发者

Math comparison operating in Django templates

开发者 https://www.devze.com 2023-01-05 18:00 出处:网络
i want to compare do simple math in django template like {% forloop.counter > 5 %} 开发者_运维百科 {% endfor %}

i want to compare do simple math in django template

like {% forloop.counter > 5 %} 开发者_运维百科 {% endfor %}

how do i achieve this?


You can do that with the if tag in Django 1.2

{% for blip in blah %}
    {% if forloop.counter > 5 %}
    {# Do somthing #}
    {% endif %}
{% endfor %}

If you are still using an earlier version of Django then you can check out the smart if tag on djangosnippets: http://djangosnippets.org/snippets/1350/

0

精彩评论

暂无评论...
验证码 换一张
取 消