Middleware that makes the current request available from anywhere.
crequest takes care of current request in silent way.
crequest will bring you current request object of your Django application from anywhere in your code.
django-crequest is available on http://pypi.python.org/pypi/django-crequest So it can be installed it by pip:
$ python pip install django-crequest
Or you can grab the latest version tarball and
$ python setup.py install
To enable django-crequest in your project
Add crequest to INSTALLED_APPS in your settings.py
Add crequest.middleware.CrequestMiddleware to MIDDLEWARE_CLASSES after the authentication and session middleware.
django-crequest currently can be run on multiple python versions:
First import the crequest’s middleware:
from crequest.middleware import CrequestMiddleware
Get the current request ;):
current_request = CrequestMiddleware.get_request()
Set the current request in UnKnown situations:
Return iam_request if there is no current request:
And finally delete:
The middleware automatically sets/deletes the current request for HTTP requests. For other uses (management commands, scripts), you will need to do this yourself.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Hashes for django-crequest-2018.5.11.tar.gz