Django Template Filter - length

Definition and Usage

The length filter returns the number of items in an object.

For strings, the length filter returns the number of characters:

Example

Return the number of characters in a string:

<h1>{{ firstname|length }}</h1>

Syntax

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

{{ value|length }}