|length_is Filter

Deprecated. Use length with comparison instead.

Logic As Markdown

Argument
n (required) – the length to compare value to.
Availability
Deprecated in Django 4.2

Documentation

Returns True if the length of the value is n. Otherwise, it returns False.

This is most useful in a condition.

Variable

veggies = ['Tomatoes', 'Cucumbers', 'Peas']

Template

{% if veggies|length_is:3 %}
  <p>Looks like a trio of veggies tonight!</p>
{% endif %}

Result

<p>Looks like a trio of veggies tonight!</p>

Commentary

Maybe we are missing something, isn't using the length filter just as easy?

{% if veggies|length == 3 %}
  <p>Looks like a trio of veggies tonight!</p>
{% endif %}

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

Send Feedback

Official Documentation
This page last updated on December 3, 2025