Middleware that makes the current request available from anywhere.
Project description
Overview
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.
Installing
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.
Supported Python versions
django-crequest currently can be run on multiple python versions:
Python 2
Python 3
PyPy
How to use
First import the crequest’s middleware:
from crequest.middleware import CrequestMiddleware
Get the current request ;):
current_request = CrequestMiddleware.get_request()
Done.
In depth & Complex details
Set the current request in UnKnown situations:
CrequestMiddleware.set_request(request)
Return iam_request if there is no current request:
CrequestMiddleware.get_request(iam_request)
And finally delete:
CrequestMiddleware.del_request()
The middleware automatically sets/deletes the current request for HTTP requests. For other uses (management commands, scripts), you will need to do this yourself.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file django-crequest-2018.5.1.tar.gz
.
File metadata
- Download URL: django-crequest-2018.5.1.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3cb18c13ee7567b4c4c0afb806f5ceba4b9c972954b9a07ad1c5ae344a9f42e6 |
|
MD5 | aee16c7bb6f6da5519805f531b420c81 |
|
BLAKE2b-256 | ac3680fc1d95cea52f5ff1cc3bbf338c8e1a18388b5b75b0c316f62afdf69e89 |