Used to include one template in another.
Parent Template
{% block main %} <p>Content before include</p> {% include 'asides/book-ad.html' %} <p>Content after include</p> {% endblock main %}
Included Template: templates/asides/book-ad.html
<aside> <p><strong>Read our Python Book!</strong></p> </aside>
Result
<p>Content before include</p> <aside> <p><strong>Read our Python Book!</strong></p> </aside> <p>Content after include</p>
Commentary
This should not be used to include headers and footers. Use Template Inheritance for that kind of thing. Use the
include
tag to include asides or callouts that show up on some, but not all pages.Pagination Include
A great use case for the include tag is pagination, which could go on any
ListView
template. Here is a Bootstrap pagination nav:The resulting nav will look like this: