Skip to main content

Django middleware that keep request instance for every thread.

Project description

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()
        ...

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

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

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page