Setup/Usage
Install using pip install django-threadlocals
Add threadlocals.middleware.ThreadLocalMiddleware to your MIDDLEWARE_CLASSES setting.
Then use it as follows:
Example usage:
from threadlocals.threadlocals import get_current_request
request = get_current_request()
Caveat Emptor
Storing the request in threadlocals goes against several django core developers' strong inclinations against using threadlocals. See this thread on django-users for a more in-depth discussion. We recommend you not do this unless you have a really good reason to do so. We feel like we had a really good reason (the only one we've come across so far): Having the request in threadlocals is the core piece that allowed us to build a true multi-tenant system on top of django where the site is resolved dynamically based on the current host, and objects are filtered based on the current host. With the current version of django, this is nearly impossible to do without the request in threadlocals. This was a very significant and advanced undertaking, but we're happy with the results.
Tests
To run tests:
python tester/manage.py test
Metadata
Release files for django-threadlocals 0.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-threadlocals-0.10.tar.gz | 5.7 kB | Without provenance | Details for django-threadlocals-0.10.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_threadlocals-0.10-py3-none-any.whl | Python 3 | none | any | Details for django_threadlocals-0.10-py3-none-any.whl |
Total release size: 12.3 kB
Release files / django-threadlocals-0.10.tar.gz
| Download URL | django-threadlocals-0.10.tar.gz |
|---|---|
| Size | 5.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c06a4c6701a56bcca2acd0bd655aaa136501ab7e5e6327ab7245be629906432a
|
|
BLAKE2b-256 checksum How to use checksums |
60b48defa1d5de9efa81b75b90baccd8607de1a2abd24c0d25a630d9183a1b6f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.7.1 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.7.0
|
Release files / django_threadlocals-0.10-py3-none-any.whl
| Download URL | django_threadlocals-0.10-py3-none-any.whl |
|---|---|
| Size | 6.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fd5e2cb36224163a53f326baddfc36251d150466234a16d8f97f54ad92bce89d
|
|
BLAKE2b-256 checksum How to use checksums |
0b02181f5c3e8f6da800bc8ee4089a38878842d6f1c65054f0ffc0bd042aad47
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.7.1 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/3.7.0
|
Security for django-threadlocals 0.10
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.