Skip to main content

django-request-context

Django middleware which provide request and g object. all of which are accessible everywhere, and thread isolation, just like used in flask.

Installing

Install and update using pip:

pip install django-request-context

Usage

  1. Add RequestContextMiddleware to MIDDLEWARE in settings.py
import django_request_context

MIDDLEWARE = [
   ...
   'django_request_context.RequestContextMiddleware',
   ...
   ] 
  1. You can get request and g objects anywhere in the project throughout the life cycle of the request. just import:
from django_request_context import request, g

why do you need this?

when your django project is big enough and the function call stack is deep. if your want to get request object in the bottom of the call stack, you need to transfer request as parameters layer-by-layer, this can help you get request directly. the request you import from django-request-context is readonly object, if your want to convey some message you can user g object, this is a writeable object. the behavior of the request and g objects is exactly the same as in the flask.

Metadata

Release files for django-request-context 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-request-context 0.1.0
File Size Uploaded Provenance Actions
django-request-context-0.1.0.tar.gz 3.6 kB Without provenance Details for django-request-context-0.1.0.tar.gz

Release files / django-request-context-0.1.0.tar.gz

Download URL django-request-context-0.1.0.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
4b004431614078f9ee3f406c42befc68232db5ef26d33b5d20fa2061ca859ebf
BLAKE2b-256 checksum
How to use checksums
c56428edde68a05a6654b1fe407a724cc2cf83167642c2cebc0155a9054978f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6

Security for django-request-context 0.1.0

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page