---
title: '|length'
description: returns the length of a value.
date: '2026-08-02'
categories:
  - Filter
  - Number
canonical: https://coolify.djangotemplatetagsandfilters.com/filters/length/
doc_link: https://docs.djangoproject.com/en/6.0/ref/templates/builtins/#length
---

# |length

returns the length of a value.

## Documentation

Returns the length of a value, which can be a string or a sequence.

### Variable

```django
classes = {
    'Python': [
        'Intro Python', 'Advanced Python', 'Data Science', 'Django'
    ],
    'Databases': [
        'Intro PostgreSQL', 'Intro MySQL', 'Intro SQL Server', 'Intro Oracle'
    ],
    'Web': [
        'HTML', 'CSS', 'JavaScript'
    ],
    'XML': [
        'Intro XML'
    ]
}
```

### Template

```django
<ol>
  {% for category, titles in classes.items %}
    <li>
      {{ category }}: {{ titles|length }}
      class{{ titles|pluralize:"es" }}
    </li>
  {% endfor %}
</ol>
```

### Result

```django
<ol>
    <li>Python: 4 classes</li>
    <li>Databases: 4 classes</li>
    <li>Web: 3 classes</li>
    <li>XML: 1 class</li>
</ol>
```
