Skip to main content

Allows view code to exit early and return a given HttpResponse by raising an exception

Project description

django_early_return

Installation

  • pip install django_early_return
  • add 'django_early_return.EarlyReturnMiddleware' to MIDDLEWARE in your settings
  • optionally, add 'django_early_return' to INSTALLED_APPS, if you want to run our tests when executing python manage.py test

Usage

Any view code (or middleware code, if that middleware is installed after EarlyReturnMiddleware) can now instantiate EarlyReturn with any HttpResponse, and that response will be returned to the user:

    if not request.user.has_perm('my_app.some_permission'):
        raise django_early_return.EarlyReturn(http.HttpResponseForbidden())

For code in helper functions/middleware/etc., this is often more convenient than passing a response back to the actual view code.

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_early_return-0.0.0.tar.gz (2.1 kB view details)

Uploaded Source

Built Distribution

django_early_return-0.0.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file django_early_return-0.0.0.tar.gz.

File metadata

  • Download URL: django_early_return-0.0.0.tar.gz
  • Upload date:
  • Size: 2.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.10

File hashes

Hashes for django_early_return-0.0.0.tar.gz
Algorithm Hash digest
SHA256 84231c165766ae0cd01188ea318a12379b170f41e4851b8d340ffa8ce97ade82
MD5 46e05ae9e82646598c3c22f188d0830d
BLAKE2b-256 7e212aef335a6256e4dc7ef007ea79fbf6547ac3efc7bb1ec8a39548b7c02559

See more details on using hashes here.

File details

Details for the file django_early_return-0.0.0-py3-none-any.whl.

File metadata

  • Download URL: django_early_return-0.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.10

File hashes

Hashes for django_early_return-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f0cad0c2ee9fbe99b5572aa3d605461da96c83c335f8028f13349f843fa69e2c
MD5 620b7dcc2e59de56b0fb039039c5f4cc
BLAKE2b-256 e6060e60b3692da7b3d0df0cb0308d871aac8e24ffc4aa675ae4b2bdecc5f819

See more details on using hashes here.

Supported by

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