Opened 5 years ago

Closed 5 years ago

#13808 closed (worksforme)

Setting handler404 and/or handler500 in main does not work.

Reported by: josho Owned by: nobody
Component: Core (Other) Version: 1.2
Severity: Keywords: urls error handler
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


Setting handler404 or handler500 in the projects main does not appear to work. I've tried this on 1.2, 1.2.1 and trunk (currently r13370) using both strings and callables as the value, and simply cannot define my own handers for error messages. No matter what I do it still uses the defaults. I have not yet managed to track down the cause.

Change History (1)

comment:1 Changed 5 years ago by kmtracey

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to worksforme
  • Status changed from new to closed

I do exactly this in one of my projects so I'm not sure how to diagnose what issue you are seeing, but I have confirmed it works for me on 1.1 and current trunk. For reference my project's main file is structured like so:

from django.conf.urls.defaults import *
from django.contrib import admin

from django import template
from django import http


urlpatterns = patterns('',
# snipped actual urlpatterns

handler404 = 'urls.custom_404_view'
handler500 = 'urls.custom_500_view'
def custom_404_view(request, template_name='404.html'):
# snipped custom 404 view code

def custom_500_view(request, template_name='500.html'):
# snipped custom 500 view code
Note: See TracTickets for help on using tickets.
Back to Top