django-error-pages

Use any HTTP error status with Django
Download

django-error-pages Ranking & Summary

Advertisement

  • Rating:
  • License:
  • GPL
  • Publisher Name:
  • James Roe
  • Publisher web site:
  • https://github.com/Roejames12/

django-error-pages Tags


django-error-pages Description

Use any HTTP error status with Django django-error-pages is an app that 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, 510Configurability & ExtendibilityDjango Error Pages is very easy to use!How easy it is to raise a 403 forbidden:```pythonfrom django.shortcuts import render_to_responsefrom error_pages.http import Http403def 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.```apacheconfErrorDocument 400 /__errorpage__/?code=400```Using mod_rewrite, you should be able to get the error page to render without changing the URL.Configuring & Setting up* Add it to your middleware```pythonMIDDLEWARE_CLASSES = ( ... 'error_pages.middleware.ErrorPageMiddleware',)```* And add the URL configuration to your root URL's```pythonfrom django.conf.urls.defaults import patterns, urlurlpatterns = patterns('', ... url(r'^__errorpage__/$', 'error_pages.views.display_error'),)```Installing* Download django-error-pages from https://github.com/Roejames12/django-error-pages/tarball/master* Or `pip install django-error-pages`* `pip install django-error-pages==dev` for the absolute bleeding edge. Requirements: · Python · Django What's New in This Release: · Improved docs with new changes Refactored middleware. · It now will catch all Django error status codes and handle them. · Additionally, you now have the option to disable specific error pages or even all of them.


django-error-pages Related Software