---
title: '{% firstof %}'
description: returns the first argument in a list of arguments that evaluates to `True`.
date: '2026-08-02'
categories:
  - Template Tag
  - Logic
canonical: https://www.djangotemplatetagsandfilters.com/tags/firstof/
doc_link: https://docs.djangoproject.com/en/6.0/ref/templates/builtins/#firstof
---

# {% firstof %}

returns the first argument in a list of arguments that evaluates to `True`.

## Documentation

Returns the first argument in a list of arguments that evaluates to `True`.

### Variables

```django
a = False
b = 0
c = ""
d = "hello"
```

### Template

```django
{% firstof a b c d %}
```

### Result

```django
hello
```

The tag allows for a default string literal:

```django
{% firstof a b c d "goodbye" %}
```

The default string will be used if all of the preceding arguments evaluate to `False`.
