Skip to content

Multiple Template Inheritance, cannot inherit a block across multiple templates #1944

Discussion options

You must be logged in to vote

I've created an example app based on what you've described, and I'm seeing the same result as you. I've looked over the docs and I can't find anything explaining the use of blocks with includes, but it's evident that blocks don't work with template includes.

Template includes will work with template variables though.

{% for box in boxes %}
    {% include "render_box.html" %}
{% endfor %}

{{ box }} will be able to be seen by render_box.html

A Macro or a Context Processor is probably what you want to look into to solve the issue you're having.

For example, you'd replace {% include 'header.html' %} with a block:

base.html

<!DOCTYPE html>
<html>
   {% block header %}{% endblock %}
    <body>
...

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by OleksandrMyronchuk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants