Skip to main content

Django middleware that keep request instance for every thread.

Install

pip install django-middleware-global-request

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 function get_request from django_global_request.middleware

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.1.tar.gz (2.3 kB view details)

Uploaded Source

File details

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

File metadata

File hashes

Hashes for django-middleware-global-request-0.1.1.tar.gz
Algorithm Hash digest
SHA256 04e56a646262de77d329171494e6e744bcaa10847696b356843c103644a233e0
MD5 49bb63589e451ac412572bd1f2c3a121
BLAKE2b-256 8617d282da88c39609d03ee0a92e27c8c8e7767ca7a07a2b3e9845d09931f382

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