Metadata-Version: 2.1
Name: django_early_return
Version: 0.3.0
Summary: Allows view code to exit early and return a given HttpResponse by raising an exception
Home-page: UNKNOWN
Author: Alex Fischer
Author-email: alex@quadrant.net
License: UNKNOWN
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE

# 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:
```python
    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.

