---
title: '|default'
description: used to provide a default string when the variable evaluates to `False`.
date: '2026-08-02'
categories:
  - Filter
  - Logic
canonical: https://coolify.djangotemplatetagsandfilters.com/filters/default/
doc_link: https://docs.djangoproject.com/en/6.0/ref/templates/builtins/#default
---

# |default

used to provide a default string when the variable evaluates to `False`.

## Documentation

Used to provide a default string when the variable evaluates to `False`.

### Variable

```django
inventory = {
    'gloves': 0,
    'hats': 51,
    'scarves': 2,
    'socks': 13
}
```

### Template

```django
<ol>
  {% for item, remaining in inventory.items %}
    <li>{{ item }}: {{ remaining|default:"out of stock" }}</li>
  {% endfor %}
</ol>
```

### Result

```django
<ol>
  <li>gloves: out of stock</li>
  <li>hats: 51</li>
  <li>scarves: 2</li>
  <li>socks: 13</li>
</ol>
```
