Tutorials References Exercises Videos Menu
Free Website Get Certified Upgrade

Template Filter - length_is


Check if there are 3 items in the list:

<h1>{{ fruits|length_is:3 }}</h1>
Run Example »

Definition and Usage

The length_is filter returns True if the length of the object is the same as the specified number.

This can be useful when you are dealing with if statements:


Write "Hello" if firstname has 5 characters:

{% if firstname|length_is:5 %}
{% endif %}
Run Example »


{{ value|length_is:len }}

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
len Required. A number to check if the object's length is the same as.