开发者

How to set variables in base template in django?

开发者 https://www.devze.com 2022-12-25 02:16 出处:网络
i have template base.html and some children templates. I don\'t know how to set开发者_运维知识库 variables for base.html

i have template base.html and some children templates. I don't know how to set开发者_运维知识库 variables for base.html

for example if i have {% for u in users %}{% endfor %} where do I assign it to users? is there some parent view for all views?


If you want certain variables to be available in all templates, you could write a template context processor (docs) and make sure you always use RequestContext when rendering templates.


You don't assign variables separately to parent templates. A template extends a parent template, and the whole thing just has one context for variables.

I suggest you reread the Django documentation on templates and inheritance.

0

精彩评论

暂无评论...
验证码 换一张
取 消