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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_early_return-0.4.0-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_early_return-0.4.0.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/34.0 requests/2.26.0 requests-toolbelt/0.10.1 urllib3/1.26.7 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.15

File hashes

Hashes for django_early_return-0.4.0.tar.gz
Algorithm Hash digest
SHA256 c33fec66d317918908859af4b1d1bbf5044b4f5c44208d641cd50bb3d3cef156
MD5 b7b0536e2eb5faef7c4fcec676b439aa
BLAKE2b-256 34cb865bd2caa185d95b02e69ada8afcf67d71e912d427b14ecffcafc65c5114

See more details on using hashes here.

File details

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

File metadata

  • Download URL: django_early_return-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.9.6 readme-renderer/34.0 requests/2.26.0 requests-toolbelt/0.10.1 urllib3/1.26.7 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.15

File hashes

Hashes for django_early_return-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1986f18fe6c3c5f2ae60a5d5c3084836b259a46abf65afe55b512fe3ebf6d099
MD5 c8e41704f47d4a7f3bc6db31f6958650
BLAKE2b-256 7f4216c87bcb70f50f87760c676f4171845ad699f02ecc92a02664dc22837aeb

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