Skip to main content

Use any HTTP error status with Django.

Project description

Django Error Pages
==================

Django Error Pages extends Django to allow you to raise and handle any type of
HTTP error, such as 400, and 403.

It behaves just like the default Django 404 and 500 error pages, which render
404.html and 500.html respectively inside your apps template folder, but display
some information in DEBUG mode.

It is very flexible, and covers a wide range of error codes:
400-418, 422-426
500-505, 507, 509, 510

Configurability & Extendibility
-------------------------------

Django Error Pages is very easy to use!

How easy it is to raise a 403 forbidden:

```python
from django.shortcuts import render_to_response

from error_pages.http import Http403

def homepage(request):
if user is unauthorized:
raise Http403
return render_to_response('index.html')
```

And of course, it'll render a 403.html template for you if DEBUG mode is off.

Also included is the ability to render your Django template error pages directly from Apache.

```apacheconf
ErrorDocument 400 /__errorpage__/?code=400
```

Using mod_rewrite, you should be able to get the error page to render without changing
the URL.

Installing
----------

* Download django-error-pages from https://github.com/Roejames12/django-error-pages/tarball/master
* or just `pip install django-error-pages`

* Now just add it to your middleware!

```python
MIDDLEWARE_CLASSES = (
...
'error_pages.middleware.ErrorPageMiddleware',
)
```

Project details


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