N
N
Nik_Set_72017-04-22 15:19:41
Django
Nik_Set_7, 2017-04-22 15:19:41

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

1 answer(s)
S
sim3x, 2017-04-22
@Nik_Set_7

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%}

https://docs.djangoproject.com/en/1.11/ref/templat...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question