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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: django_early_return-0.1.0.tar.gz
  • Upload date:
  • Size: 3.0 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.1.0.tar.gz
Algorithm Hash digest
SHA256 e4493a9afda5df3b0be20c3ad1215d6cbbe0290f0f9186e312e60a92bb991ed9
MD5 794cdcb2ef30404906f1768205e3360b
BLAKE2b-256 2d23a122f6b74502e414e341e1796c4654ab6429c35c9a7c46abfd107774221d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for django_early_return-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2f92aa3e90e67b5fa9c4b44d0f70a65f465d0af65e7da111392862720d734cb9
MD5 9be50f655de42c70c2ac16b877ecde06
BLAKE2b-256 e81a0ed334904e46f570f550bbc27c60a1b7d392cd5345097e1b58670ad74584

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