0

for example: in the templates you will use your site name a lot of times. in the future if you want to change your website name you must edit all templates files you wrote your site name in them is there a way to define a variable and use that variable in all templates without using context in views

I tried to define and use settings.py properties with this code but doesn't work

{{SITE_NAME}}
  • Does this answer your question? [django how to use a variable globally](https://stackoverflow.com/questions/28792142/django-how-to-use-a-variable-globally) – JamesG Jan 13 '20 at 22:14

2 Answers2

0

You need a context processor: https://www.webforefront.com/django/setupdjangocontextprocessors.html

0

Use a context processor, here is an example for your use case:

How can I get the domain name of my site within a Django template?

panchicore
  • 11,451
  • 12
  • 74
  • 100