[Solved]-Modulus/Modulo equivalent operator/function in django templates?

29👍

divisibleby

Returns True if the value is divisible by the argument.

For example:

{{ value|divisibleby:"3" }}

django template doc

👤iMom0

2👍

forlopp count divisible by 2

{% if forloop.counter|divisibleby:2 == 0 %}

forloop count not divisible by 2

{% if forloop.counter|divisibleby:2 != 0 %}

Leave a comment