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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_early_return-0.2.0.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.10

File hashes

Hashes for django_early_return-0.2.0.tar.gz
Algorithm Hash digest
SHA256 6afc607beb5b5d1e19dfe9a776c2a845eb56aff07f7bf74193d9ceca3b4d3c4d
MD5 54e310d5688301fc0f3ecc30193b46db
BLAKE2b-256 df78e60cf073d89c5aab06bb8c968e6c1b0dd9fa700058a57df237a2e543a609

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_early_return-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cb5a73f527b466b98c462c31e50a941272614c420566357d755a6b194bb5496e
MD5 878eb41946e7eb05647617daf76f5163
BLAKE2b-256 6084b0fe0ce63bdcf61c90cdaafe53d604ad2adf7709fe009d9a37df68baf9a2

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