About Template Partials

Django 6 introduces a new feature - template partials. These are template snippets that you can reuse in multiple places of the page.

{% extends "base.html" %}

{% block title %}{% partial page_title %}{% endblock %}

{% block content %}
<h1>{% partialdef page_title inline %}Hello World!{% endpartialdef %}</h1>
<p>This is the homepage.</p>
{% endblock %}

The inline parameter defines whether to render it in place or just save it into memory.

At the time of writing, partial definitions and their usage need to remain within the same template.

Tips and Tricks Programming Django 6.x