开发者

Math comparison operating in Django templates

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜