django templates: include and extends

后端 未结 7 2001
没有蜡笔的小新
没有蜡笔的小新 2020-12-07 10:37

I would like to provide the same content inside 2 different base files.

So I\'m trying to do this:

page1.html:

{% extends \"base1.html\" %}
         


        
7条回答
  •  一生所求
    2020-12-07 11:15

    This should do the trick for you: put include tag inside of a block section.

    page1.html:

    {% extends "base1.html" %}
    
    {% block foo %}
       {% include "commondata.html" %}
    {% endblock %}
    

    page2.html:

    {% extends "base2.html" %}
    
    {% block bar %}
       {% include "commondata.html" %}
    {% endblock %}
    

提交回复
热议问题