Opened 11 years ago

Closed 11 years ago

#20640 closed Bug (fixed)

`get_deleted_objects` causes an error if there is no change view.

Reported by: Keryn Knight <django@…> Owned by: Rainer Koirikivi
Component: contrib.admin Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The format_callback used for rendering the objects to be deleted on the confirmation screen doesn't attempt to fail gracefully, if there is no named URL fitting the "namespace:appname_modelname_change" - if get_urls() is overridden on a ModelAdmin subclass to either change, remove or replace the change_view, the delete page will never work due to a NoReverseMatch.

Proposed solution: NoReverseMatch should be caught, and the format should end up the same as if has_admin were False.

(note: link to GitHub above is to the latest revision in master, as I write this.)

Change History (5)

comment:1 by Rainer Koirikivi, 11 years ago

Triage Stage: UnreviewedAccepted

Created a test project and verified that the bug occurs.

comment:2 by Rainer Koirikivi, 11 years ago

Owner: changed from nobody to Rainer Koirikivi
Status: newassigned

comment:3 by Rainer Koirikivi, 11 years ago

Has patch: set

Pull request: https://github.com/django/django/pull/1485
Tests pass under postgresql and sqlite

Version 1, edited 11 years ago by Rainer Koirikivi (previous) (next) (diff)

comment:4 by Rainer Koirikivi, 11 years ago

Related issue (NoReverseMatch in changelist_view if the "namespace:appname_modelname_change" url is removed): #20934

comment:5 by Tim Graham <timograham@…>, 11 years ago

Resolution: fixed
Status: assignedclosed

In 3c0300405009b82b52fd15483371097221662fcd:

Fixed #20640 -- Avoided NoReverseMatch in get_deleted_objects

The default delete action resulted in a NoReverseMatch if it were to
list any Model with a ModelAdmin with get_urls overridden to remove
the change url. Catching the error and not displaying the link in that
case, as was already done for models with no registered admins.

Thanks Keryn Knight for the report.

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