Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is context processor only way to access global variable in Django?

I am creating a website and i have to access golbal variables for the footer section and i found the context processor one way to access global variable and my question is that Is context processors one and only way to access global variable in django ?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Technically you can use middleware (see https://www.valentinog.com/blog/django-middleware/), but context processors are by far the better option.

I guess the use case for middleware would be if you need to change what parameters your passing to the context based off of the response, rather than the request like a context processor allows you to do.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading