Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I override standard handler404, handler403, handler500 in Django?

I have tried using https://docs.djangoproject.com/en/dev/topics/http/views/ tutorial, but still I am getting the standard 404 html page. I want to switch in to my custom view

handler404 = 'myview.views.custom_page_not_found' ,

I did debug it (using eclipse), then the value of handler404(old value -'django.config.default.views.page_not_found) is changed to the new value I have given ('myview.views.custom_page_not_found'). But it's still showing the older 404 page. And I have changed settings.py DEBUG into False then it shows the custom page. But it got some disadvantages (it won't load static files and all, DEBUG = false is not the right way) so I had to reset to True.

Do I have to make some other modification for implementing this?

like image 623
The Hun Avatar asked Oct 03 '13 13:10

The Hun


1 Answers

I think you can not change the 404 page in DEBUG = True mode without difficulty.

There is a hint in the documentation (https://docs.djangoproject.com/en/dev/topics/http/views/#the-404-page-not-found-view):

If DEBUG is set to True (in your settings module), then your 404 view will never be used, and your URLconf will be displayed instead, with some debug information.

like image 57
shry Avatar answered Oct 30 '22 07:10

shry