Opened 18 years ago

Closed 18 years ago

#2875 closed defect (fixed)

[patch] Bad URLPattern results in potentially misleading exception

Reported by: Matt McClanahan <cardinal@…> Owned by: Adrian Holovaty
Component: Core (Other) Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In django/core/urlresolvers.py, get_mod_func() raises a ValueError exception if the callback does not contain any dots. This rare situation is almost certainly caused by the user specifying the view callback incorrectly (E.g, 'edit_object' instead of 'myproject.myapp.views.edit_object')

To clarify the cause of the error, this patch makes get_mod_func() return the full callback string as the module name and a blank function name. The calling functions then raise either a ViewDoesNotExist, or in the case of RegexURLPattern.reverse(), a NoReverseMatch.

While this bug only affects the URL which was specified incorrectly in the app/project it belongs to, it also has the slightly more serious effect of completely breaking the admin's view documentation.

Attachments (1)

urlresolver-getmodfunc.diff (582 bytes ) - added by Matt McClanahan <cardinal@…> 18 years ago.

Download all attachments as: .zip

Change History (2)

by Matt McClanahan <cardinal@…>, 18 years ago

Attachment: urlresolver-getmodfunc.diff added

comment:1 by Jacob, 18 years ago

Resolution: fixed
Status: newclosed

(In [4047]) Fixed #2875: made urlresolvers.get_mod_func() deal with non-qualified callbacks better. Thanks, Matt McClanahan.

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