A
A
Andrei1penguin12022-01-10 02:11:05
Django
Andrei1penguin1, 2022-01-10 02:11:05

How to insert html blocks from other files in django?

Let's say there are 2 html files, in one there is arbitrary code, in the other there are several different blocks.
The task is to insert a specific block from the second file to a specific location in the first.
Let me explain with an example:
file1.html:

<div>
    <!-- Здесь должен появится блок с id=2 из 
          второго файла -->
</div>

file2.html:
<div id="1"></div>
<div id="2"></div>
<div id="3"></div>

{% include " file2.html " %} does n't work because only one specific block needs to be imported.

Tell me how to solve such a problem?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question