Returns True
if the value is divisible by n
, and False
otherwise.
Variable
age = 33
Template
{{ age|divisibleby:2 }} {{ age|divisibleby:3 }}
Result
False True
Argument: n
(required)
– divisor
Returns True
if the value is divisible by n
, and False
otherwise.
age = 33
{{ age|divisibleby:2 }} {{ age|divisibleby:3 }}
False True
Did we get something wrong? Is there a use case for the
divisibleby
filter that we should add?
Please let us know.
Commentary
This Django template filter is similar to mod / modulus. It is useful for creating columns when using Bootstrap or some similar library.
Example Code: