数学比较在Django模板中运行 [英] Math comparison operating in Django templates

查看:144
本文介绍了数学比较在Django模板中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想比较在django模板中做简单的数学

i want to compare do simple math in django template

像{%forloop.counter> 5%}
{%endfor%}

like {% forloop.counter > 5 %} {% endfor %}

我如何实现这一点?

推荐答案

a href =http://docs.djangoproject.com/en/1.2/ref/templates/builtins/#if =nofollow noreferrer> if tag 在Django 1.2

You can do that with the if tag in Django 1.2

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

如果您仍然使用早期版本的Django,那么您可以在djangosnippets上查看smart if标签: http://djangosnippets.org/snippets/1350/

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/

这篇关于数学比较在Django模板中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆