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.
Also by me
Django Messaging 🎅🏼
For Django-based social platforms.
Django App for You
Django Paddle Subscriptions 🎅🏼
For Django-based SaaS projects.
Django App for You
Django GDPR Cookie Consent 🎅🏼
For Django websites that use cookies.
Django App for You