divisibleby Filter

Number

Argument: n (required) – divisor

Documentation

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

Commentary

Hard to think of a use case for this one. If you need to do something like toggle between CSS classes, use the cycle tag.


Did we get something wrong? Is there a use case for the divisibleby filter that we should add? Please let us know.

Send Feedback

Official Documentation
This page last updated on Sept. 16, 2020, 7:34 p.m. EST