Skip to main content

Django middleware that keep request instance for every thread.

Usage:

  1. Add django application django_global_request to INSTALLED_APPS in settings.py

INSTALLED_APPS = [
    ...
    'django_global_request',
    ...
]
  1. Add GlobalRequestMiddleware to MIDDLEWARE in settings.py

MIDDLEWARE = [
    ...
    'django_global_request.middleware.GlobalRequestMiddleware',
    ...
]
  1. Get request instance with from django_global_request.middleware import get_request

from django_global_request.middleware import get_request

class TestModel(models.Model):

    field1 = models.CharField(max_length=32)

    def hello(self):
        request = get_request()
        ...

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-middleware-global-request-0.1.0.tar.gz (2.3 kB view details)

Uploaded Source

File details

Details for the file django-middleware-global-request-0.1.0.tar.gz.

File metadata

File hashes

Hashes for django-middleware-global-request-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2940069b35147bcc9631c0cb8624a77429cb119d95b8944022b67bc642996c75
MD5 9d3b297525d32a78dab27bf1f7f1e56e
BLAKE2b-256 1cfc2404e36717737bc8141a0e792b708ca79fcbfd0563e18931231aab90d6f8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page