---
title: '{% cycle %}'
description: cycles through list of arguments.
date: '2026-08-02'
categories:
  - Template Tag
  - Logic
canonical: https://coolify.djangotemplatetagsandfilters.com/tags/cycle/
doc_link: https://docs.djangoproject.com/en/6.0/ref/templates/builtins/#cycle
---

# {% cycle %}

cycles through list of arguments.

## Documentation

Cycles through list of arguments.

### Variable

```django
fruits = ['Apples', 'Bananas', 'Pears', 'Grapes', 'Oranges']
```

### Template

```django
<ol>
{% for fruit in fruits %}
  <li class="{% cycle 'odd' 'even' %}">{{ fruit }}</li>
{% endfor %}
</ol>
```

### Result

```django
<ol>
  <li class="odd">Apples</li>
  <li class="even">Bananas</li>
  <li class="odd">Pears</li>
  <li class="even">Grapes</li>
  <li class="odd">Oranges</li>
</ol>
```

## Commentary

To start the sequence over part way through - typically inside a nested loop - see [`resetcycle`](/tags/resetcycle/).

The [official documentation](https://docs.djangoproject.com/en/6.0/ref/templates/builtins/#cycle) has some good examples of more advanced usage.
