Skip to main content

Throwing web exceptions like in AioHTTP

Project description

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.


Install Django Web Exceptions:

pip install django-web-exceptions

Add it to your MIDDLEWARE:

    # ...
    # ...


Import exceptions and raise anywhere

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 like django error handlers .


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


Tools used in rendering this package:


0.1.2 (2017-05-15)

  • Clean source code from unused rows.

0.1.1 (2017-05-13)

  • Small fixes in source code and readme.

0.1.0 (2017-05-13)

  • First release on PyPI.

Project details

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