Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to test 500.html error page in django development env?

I am using Django for a project and is already in production.

In the production environment 500.html is rendered whenever a server error occurs.

How do I test the rendering of 500.html in dev environment? Or how do I render 500.html in dev, if I turn-off debug I still get the errors and not 500.html

background: I include some page elements based on a page and some are missing when 500.html is called and want to debug it in dev environment.

like image 956
lud0h Avatar asked Apr 29 '10 19:04

lud0h


1 Answers

I prefer not to turn DEBUG off. Instead I put the following snippet in the urls.py:

if settings.DEBUG:     urlpatterns += patterns('',         (r'^500/$', 'your_custom_view_if_you_wrote_one'),         (r'^404/$', 'django.views.generic.simple.direct_to_template', {'template': '404.html'}),     ) 

In the snippet above, the error page uses a custom view, you can easily replace it with Django's direct_to_template view though.

Now you can test 500 and 404 pages by calling their urls: http://example.com/500 and http://example.com/404

like image 177
shanyu Avatar answered Oct 04 '22 10:10

shanyu