Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#15343 closed (fixed)

import of handler500 is missing in django/contrib/auth/tests/

Reported by: Marco De Paoli Owned by: nobody
Component: Contrib apps Version: 1.2
Severity: Keywords: urls handler500
Cc: Marco De Paoli, afitzpatrick Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


as documented here

all urls files must contain

from django.conf.urls.defaults import *

or an explicit import for the function handler404 and handler500 ex.

from django.conf.urls.defaults import handler404, handler500

but the file django/contrib/auth/tests/ doesn't follow this rule

the consequence is that any problem that arise inside auth tests is signaled as

AttributeError: 'module' object has no attribute 'handler500'

as a temporary workaround I used this method:

  • modify django/contrib/auth/tests/ to add an explict import for handler500
  • run auth test cases and obtain the correct error message
  • restore django/contrib/auth/tests/

Nevertheless this case shows another problem

When Django outputs:

AttributeError: 'module' object has no attribute 'handler500'

it doesn't signal which file is missing handler500, and this makes the research a little bit hard

My advice is to modify slightly the urlresolver mechanism (django/core/

for example the instruction

callback = getattr(self.urlconf_module, 'handler%s' % view_type)

could be enveloped inside a try/except block that rises an exception with self.urlconf_module string in it

Change History (4)

comment:1 Changed 8 years ago by Marco De Paoli

Cc: Marco De Paoli added

comment:2 Changed 8 years ago by Carl Meyer

Resolution: fixed
Status: newclosed

In [15566]:

[1.2.X] Fixed #15343 -- Added import of handler500 and handler404 in URLconf for contrib.auth tests, so that other configuration errors that cause test failures aren't masked by 'missing handler500' errors.

comment:3 Changed 8 years ago by Carl Meyer

No fix is needed in trunk, because in trunk URLconfs are no longer required to import handler500 and handler404.

comment:4 Changed 8 years ago by afitzpatrick

Cc: afitzpatrick added
Note: See TracTickets for help on using tickets.
Back to Top