Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在其他模板中包含django模板,以便实际解析它们_Django_Django Templates - Fatal编程技术网

在其他模板中包含django模板,以便实际解析它们

在其他模板中包含django模板,以便实际解析它们,django,django-templates,Django,Django Templates,Django的继承结构快把我逼疯了 我正在创建几个皮肤,每个皮肤都有两列和三列布局: site1 - two_cols.html - three_cols.html site2 - two_cols.html - three_cols.html three_cols.html布局扩展了three_cols.html,只是在布局中添加了一个额外的列,并为内容添加了一个额外的django cms占位符 对于site1和site2,在这一阶段,几乎唯一的更改是不同的样式表名称,因此我

Django的继承结构快把我逼疯了

我正在创建几个皮肤,每个皮肤都有两列和三列布局:

site1
  - two_cols.html
  - three_cols.html
site2
  - two_cols.html
  - three_cols.html
three_cols.html布局扩展了three_cols.html,只是在布局中添加了一个额外的列,并为内容添加了一个额外的django cms占位符

对于site1和site2,在这一阶段,几乎唯一的更改是不同的样式表名称,因此我想将two_cols.html和two_cols.html移动到一个“common”目录中,并让site1和site2下的目录扩展它们

因此:

  • two_cols.html为CSS路径设置块名
  • three_cols.html扩展了three_cols.html并提供了一个额外的列
我已经为两列布局完成了这项工作,效果很好。但是,例如,对于site1中的三列布局,我想扩展site1/two_cols.html(设置CSS路径),然后只包含“common/two_cols.html”(定义额外列)的内容

这对我不起作用,因为three_cols.html包含django cms占位符标记,因为我只是“包括”模板,显然没有解析,而只是计算

换句话说,我希望site1/two_cols.html中的一些设置能够从site1/two_cols.html中使用,在site1/two_cols.html中,它们都扩展了不同的模板

总结
我的问题是如何将某个内容包含在父模板中(django文档说include不会这样做:)?

为什么不能使用普通的
扩展执行此操作<代码>三列
可以扩展
两列
并在主块内添加另一列,使用
block.super
渲染原始的两列