Is the Global Request variable in Python/Django available?

AFAIK it is not available, except you make it available.

You can copy+paste the snippets provided in the other answers, or you can use this library: https://pypi.python.org/pypi/django-crequest

Middleware to make current request always available.


Django doesn't provide a global request object (it would actually be a thread local, not a global). But there are a few techniques you can use to get the same effect yourself: http://nedbatchelder.com/blog/201008/global_django_requests.html

Tags:

Python

Django