【发布时间】:2011-09-21 15:06:18
【问题描述】:
所以根据我从模板继承中读到的内容,假设你有
base.html
content.html
content_view.py
在 content_view.py 中有一个函数,其 template_name="content.html" 和 content.html 扩展了 base.html。因此 content_view.py 中的函数返回的 locals() 被传递到 content.html 中,并且由于 content.html 扩展了 base.html,因此 locals() 也被传递到 base.html 中。
首先这是正确的吗?
第二,有没有办法将更多没有被content_view.py中的函数初始化的变量传递到base.html中?
第三,信息流总是:urls.py -> views.py -> 模板,urls.py -> views.py -> 模板 -> views.py -> 模板是否可能?如果是的话,你如何编码重定向?
非常感谢!
【问题讨论】:
-
其实这个问题不是模板继承特有的,因为模板中可用的变量是相同的,无论你是否继承......
标签: python django templates inheritance view