django templates: include and extends

后端 未结 7 2005
没有蜡笔的小新
没有蜡笔的小新 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条回答
  •  萌比男神i
    2020-12-07 11:14

    From Django docs:

    The include tag should be considered as an implementation of "render this subtemplate and include the HTML", not as "parse this subtemplate and include its contents as if it were part of the parent". This means that there is no shared state between included templates -- each include is a completely independent rendering process.

    So Django doesn't grab any blocks from your commondata.html and it doesn't know what to do with rendered html outside blocks.

提交回复
热议问题