---
title: '{% partial %}'
description: renders a template fragment defined with `partialdef`.
date: '2026-08-02'
categories:
  - Template Tag
  - Utility
canonical: https://www.djangotemplatetagsandfilters.com/tags/partial/
doc_link: https://docs.djangoproject.com/en/6.0/ref/templates/builtins/#partial
---

# {% partial %}

renders a template fragment defined with `partialdef`.

## Documentation

Renders a template fragment that was previously defined with the [`partialdef`](/tags/partialdef/) tag.

### Arguments

- `partial_name` (required) – The name of the template fragment to render.

### Template

```django
{# First, define the partial #}
{% partialdef button %}
  <button class="btn btn-{{ style }}">{{ label }}</button>
{% endpartialdef %}

{# Then render it multiple times #}
{% with style="primary" label="Save" %}
  {% partial button %}
{% endwith %}

{% with style="secondary" label="Cancel" %}
  {% partial button %}
{% endwith %}

{% with style="danger" label="Delete" %}
  {% partial button %}
{% endwith %}
```

### Result

```django
<button class="btn btn-primary">Save</button>
<button class="btn btn-secondary">Cancel</button>
<button class="btn btn-danger">Delete</button>
```

### Using Partials in Loops

Partials work well within loops, using the current context for each iteration:

### Template

```django
{% partialdef item-row %}
  <tr>
    <td>{{ item.name }}</td>
    <td>{{ item.price }}</td>
  </tr>
{% endpartialdef %}

<table>
  {% for item in items %}
    {% partial item-row %}
  {% endfor %}
</table>
```

## Commentary

The `partial` tag works hand-in-hand with [`partialdef`](/tags/partialdef/). Together, they provide a clean way to define and reuse template fragments without creating separate template files.

This is especially useful for:

- Repeating UI components (buttons, cards, list items) within a single template
- Reducing duplication when the same markup appears multiple times
- Keeping related template code together instead of splitting into many small files

For more details and examples, see the [`partialdef`](/tags/partialdef/) documentation.
