Code

Opened 4 years ago

Closed 4 years ago

#13808 closed (worksforme)

Setting handler404 and/or handler500 in main urls.py 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:

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.

Attachments (0)

Change History (1)

comment:1 Changed 4 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 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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.