Mathematical comparison in Django templates

I want to compare simple math in a django template

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

How do I achieve this?

0
source share
1 answer

You can do it with iftag 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, you can check the smart if tag on djangosnippets: http://djangosnippets.org/snippets/1350/ p>

0
source

Source: https://habr.com/ru/post/1752504/


All Articles