Skip to main content
https://badge.fury.io/py/django-web-exceptions.svg https://travis-ci.org/samael500/web-exceptions.svg?branch=master https://codecov.io/gh/samael500/web-exceptions/branch/master/graph/badge.svg Documentation Status

Throwing web exceptions like in AioHTTP

What and why?

In AioHTTP you can raise any response as exception (this is very cool). But Django can raise only 3+1 web exceptions.

This package allow you to raise as exception any of HTTP response.

Documentation

The full documentation is at https://web-exceptions.readthedocs.io.

Quickstart

Install Django Web Exceptions:

pip install django-web-exceptions

Add it to your MIDDLEWARE:

# settings.py
MIDDLEWARE = (
    # ...
    'web_exceptions.middleware.WebExceptionsMiddleware',
    # ...
)

Features

Import exceptions and raise anywhere

# views.py
from web_exceptions import exceptions

# ...

def index(request):
    """ Simple view raise redirectexception """
    raise exceptions.HTTPMovedPermanently('/foo')

Also you can customize any kind of exception status code as custom handler, defined in urls.py like django error handlers .

# urls.py
from myapp import views

handler300 = <callable view>
handler400 = <callable view>
handler<status_code> = <callable view>

For more example see example proj

Running Tests

Does the code actually work?

source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install tox
(myenv) $ tox

Credits

Tools used in rendering this package:

Release files for django-web-exceptions 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-web-exceptions 0.1.4
File Size Uploaded
django-web-exceptions-0.1.4.tar.gz 7.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-web-exceptions 0.1.4
File Interpreter ABI Platform
django_web_exceptions-0.1.4-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 15.0 kB

Release files / django-web-exceptions-0.1.4.tar.gz

Download URL django-web-exceptions-0.1.4.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
ee0b547090c0b5998cbe5f1d722ce86045c20340a445723bc761d38647053c3e
BLAKE2b-256 checksum
How to use checksums
4e830b5ae39f88581f82d912dd22a590730ebe459d5c05992e6a3ee46bcbc6f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / django_web_exceptions-0.1.4-py2.py3-none-any.whl

Download URL django_web_exceptions-0.1.4-py2.py3-none-any.whl
Size 7.3 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
5370c7bb18cfaa337e1c030630236df3f0a23c343c46495fcf31dd4f07e473dc
BLAKE2b-256 checksum
How to use checksums
16e081706143b600b5bcbe4bc591dbc9bded0eecc636b33be267ba73a36d6eed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 release files

0.1.3

2 release files

0.1.2

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page