Tutorials References Exercises Bootcamp Menu
Sign Up Create Website Get Certified Pro

Template Filter - divisibleby


Check if a value is divisible by 5:

{% if totalsum|divisibleby:5 %}
  <h1>Yes, it is!</h1>
{% endif %}
Run Example »

Definition and Usage

The divisibleby filter returns True if the value is divisible by the argument, otherwise it returns False.


Display the answer, is totalsum divisible by 3:

<h1>{{ totalsum|divisibleby:3 }}</h1>
Run Example »


{{ value|divisibleby:num }}

Template filters are defined by using a pipe | character followed by the name of the filter.

Arguments are defined by using a colon : character followed by the argument value.


Value Description
num Required. A number to try to divide the value with.