Opened 7 years ago

Closed 7 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: koirikivi
Component: contrib.admin Version: master
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


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 Changed 7 years ago by koirikivi

Triage Stage: UnreviewedAccepted

Created a test project and verified that the bug occurs.

comment:2 Changed 7 years ago by koirikivi

Owner: changed from nobody to koirikivi
Status: newassigned

comment:3 Changed 7 years ago by koirikivi

Has patch: set

Active work on this at:
Pull request:
Tests pass under postgresql and sqlite

Last edited 7 years ago by koirikivi (previous) (diff)

comment:4 Changed 7 years ago by koirikivi

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

comment:5 Changed 7 years ago by Tim Graham <timograham@…>

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