Opened 14 years ago

Closed 14 years ago

#13808 closed (worksforme)

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

Reported by: Josh Ourisman 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: no UI/UX: no

Description

Setting handler404 or handler500 in the projects main urls.py 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 by Karen Tracey, 14 years ago

Resolution: worksforme
Status: newclosed

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 urls.py file is structured like so:

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

from django import template
from django import http

admin.autodiscover()

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