How to add, multiply number variables in a Django template?

前端 未结 5 1850
死守一世寂寞
死守一世寂寞 2020-12-28 19:36

The JS snippet I created relies on the forloop.counter variable being available within a {% for key, value in data.items %}..{% endfor %} tag.

Is there

5条回答
  •  被撕碎了的回忆
    2020-12-28 20:03

    Use django-mathfilters. The addition filter doesn't coerce numbers to integer so you can add floats:

    {% load mathfilters %}
    {{ num1 | addition:num2 }}
    

提交回复
热议问题