---
title: '|add'
description: adds `arg` to the value.
date: '2026-08-02'
categories:
  - Filter
  - Number
canonical: https://coolify.djangotemplatetagsandfilters.com/filters/add/
doc_link: https://docs.djangoproject.com/en/6.0/ref/templates/builtins/#add
---

# |add

adds `arg` to the value.

## Documentation

Adds `arg` to the value. This can be used for adding numbers or concatenating strings.

### Variables

```django
age = 30
name = 'Nat'
```

### Template

```django
{{ name|'haniel' }} is {{ age|add:20 }}.
```

### Result

```django
Nathaniel is 50.
```

## Commentary

The `add` filter can be used to coerce a string in to an integer in a template. Consider the following:

```django
<select name="order">
  {% for field in order_fields %}
    <option value="{{ forloop.counter0 }}"
      {% if request.GET.order|add:"0" == forloop.counter0 %}selected{% endif %}
    >{{ field }}</option>
  {% endfor %}
</select>
```

Because `order` is passed on the querystring, it will be a string, but `forloop.counter0` will be an integer, so the two will never be equal. Coercing `request.GET.order` to an integer using `add` solves the problem.

An alternative would be to coerce `forloop.counter0` in to a string using the [`slugify` filter as shown here](/filters/slugify/).
