---
title: '|default_if_none'
description: outputs `default` if and only if the value is `None`.
date: '2026-08-02'
categories:
  - Filter
  - Logic
canonical: https://www.djangotemplatetagsandfilters.com/filters/default_if_none/
doc_link: https://docs.djangoproject.com/en/6.0/ref/templates/builtins/#default-if-none
---

# |default_if_none

outputs `default` if and only if the value is `None`.

## Documentation

Outputs `default` if and only if the value is `None`.

### Variables

```django
a = None
b = 0
c = ''
d = False
e = []
```

### Template

```django
<ol>
  <li>{{ a|default_if_none:"No a" }}</li>
  <li>{{ b|default_if_none:"No b" }}</li>
  <li>{{ c|default_if_none:"No c" }}</li>
  <li>{{ d|default_if_none:"No d" }}</li>
  <li>{{ e|default_if_none:"No e" }}</li>
</ol>
```

### Result

```django
<ol>
  <li>No a</li>
  <li>0</li>
  <li></li>
  <li>False</li>
  <li>[]</li>
</ol>
```

Notice that the default is only used for `a`. While all the rest evaluate to `False`, they are not `None`.
