Skip to main content

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

Project description



  • 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 test


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

Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-early-return, version 0.0.0
Filename, size File type Python version Upload date Hashes
Filename, size django_early_return-0.0.0-py3-none-any.whl (4.0 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size django_early_return-0.0.0.tar.gz (2.1 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page