Answer the question
In order to leave comments, you need to log in
How to do "double" template inheritance in Django?
I'll say right away: the question is most likely not correctly framed.
The situation is as follows: through views.py I (through render) call html file No. 1 - main_page.html
It loads through extends the main template No. 0 - index.html . Further in index.html through include I include header.html, main.html, footer.html .
Question: how to transfer the code from main_page.html to main.html (through a block, etc.)?
That is why the question is in the title: I want to pass the code not to the first html file (via extends ), but to the second file (which itself is included in template #0).
Answer the question
In order to leave comments, you need to log in
We don’t use the include if it really doesn’t improve the reading of the code We
stuff everything in index.html into blocks
In main_page.html we use block.super
{% block header %}
{{ block.super }}
{%endblock%}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question