Home > Software design >  Is context processor only way to access global variable in Django?
Is context processor only way to access global variable in Django?

Time:11-18

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 ?

CodePudding user response:

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.

  • Related