Just starting to understand django. Stuck on this moment. It is necessary to display different blocks on the page, each block is, roughly speaking, a separate application. I would still want to separate them. But it is impossible to realize this. Only one block is displayed. Main template main.html

<html> <head> </head> <body> {% block block1 %} {% endblock %} {% block block2 %} {% endblock %} {% block block3 %} {% endblock %} </body> </html> 

Each application has its own templates folder, in which the template c {% extends 'main.html' %} It is displayed separately, not together. I understand that block is not equal to view, but how then to organize joint display? And whose urls.py then refer to?

    2 answers 2

    In each block where you need to import another template, do so -

    app / template1.html

     <div>Бла бла бла</div> <div>{% include 'app/template2.html' %}</div> (здесь вы импортируете в div шаблон который нужно загрузить, так же если вы импортируете страницу с какими то параметрами их так же нужно передать: {% include 'app/templates2.html' with form=form %}) <div>Бла бла бла</div> 

      It seems to me that template tags are perfect for this business.

      You create the necessary template tag for each application, insert them in the right place, and they, in turn, tighten the logic from the necessary applications. Just not to get involved in them.

      You might also want the inserts {% include "foo / bar.html"%}

      https://docs.djangoproject.com/en/1.8/howto/custom-template-tags/ https://docs.djangoproject.com/en/1.8/ref/templates/builtins/#include