Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set variables in base template in django?

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?

like image 589
dfens Avatar asked Feb 02 '26 04:02

dfens


1 Answers

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.

like image 139
Jonny Buchanan Avatar answered Feb 03 '26 23:02

Jonny Buchanan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!