Skip to main content

Django middleware that keep request instance for every thread.

Project description

https://travis-ci.org/appstore-zencore/django-middleware-global-request.svg?branch=master

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

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

Uploaded Source

File details

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

File metadata

File hashes

Hashes for django-middleware-global-request-0.1.2.tar.gz
Algorithm Hash digest
SHA256 f6490759bc9f7dbde4001709554e29ca715daf847f2222914b4e47117dca9313
MD5 6f92e5c22e92f4e4fa09305bf565855b
BLAKE2b-256 d4e02a8ec5553ce771fd2e400f845d3bba9ddfe283f7a5b9d7d1f6880ef613c0

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