Monday, June 29, 2015

Django 1.8.2 - handler404 and handler500 refusing to work

Good afternoon all,

Perhaps someone can give me a pointer here:

I'm an old hand at Django (1.0 to 1.6) but now in 1.8.2, the documented process of writing and attaching custom handlers for '404' and '500' appears to have stopped working.

As per the dox, I have added into my ROOT url file, the required overrides:
from django.conf.urls import *
from django.contrib import admin

urlpatterns = [
    url(r'^apikey/', include('apikey.urls', namespace='apikey')),
    url(r'^admin/', include(,

handler404 = 'apikey.views.custom_handler'
handler500 = 'apikey.views.custom_handler'
I have created the default 404.html template in the apikey/templates directory and updated the site settings file to reflect this
and I can confirm that this default 404.html file is indeed getting rendered, but not by my routine:
def custom_handler(request):
    print '——>>> got to here'
    return HttpResponseNotFound('<h1>Boo! - Page not found</h1>')

I've been testing with DEBUG=False under 'python runserver'.
My custom handler never, *ever* fires when a URL not in my apikey/ file is submitted by a GET and a 404 is supposed to be raised.

I am at a complete loss as to why this isn't working, having had no issues with this custom handler process over the past 5 years :(

You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
To view this discussion on the web visit
For more options, visit

No comments:

Post a Comment