Code

Opened 8 years ago

Closed 7 years ago

#2875 closed defect (fixed)

[patch] Bad URLPattern results in potentially misleading exception

Reported by: Matt McClanahan <cardinal@…> Owned by: adrian
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: UI/UX:

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@…> 8 years ago.

Download all attachments as: .zip

Change History (2)

Changed 8 years ago by Matt McClanahan <cardinal@…>

comment:1 Changed 7 years ago by jacob

  • Resolution set to fixed
  • Status changed from new to closed

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

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.