Django

Code

Ticket #2875 (closed: fixed)

Opened 2 years ago

Last modified 2 years ago

[patch] Bad URLPattern results in potentially misleading exception

Reported by: Matt McClanahan <cardinal@dodds.net> Assigned to: adrian
Milestone: Component: Core framework
Version: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

urlresolver-getmodfunc.diff (0.6 kB) - added by Matt McClanahan <cardinal@dodds.net> on 10/05/06 04:16:12.

Change History

10/05/06 04:16:12 changed by Matt McClanahan <cardinal@dodds.net>

  • attachment urlresolver-getmodfunc.diff added.

11/06/06 23:05:17 changed by jacob

  • status changed from new to closed.
  • resolution set to fixed.

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


Add/Change #2875 ([patch] Bad URLPattern results in potentially misleading exception)




Change Properties
Action