Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#15212 closed (fixed)

get_actions() always needs to return SortedDict, not list

Reported by: philomat Owned by: nobody
Component: contrib.admin Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation:
Needs tests: Patch needs improvement:
Easy pickings: UI/UX:

Description

All docs state that get_actions() returns a dict. From documentation of ModelAdmin.get_actions():

        """
        Return a __dictionary__ mapping the names of all actions...
        """

However:

        if self.actions is None or IS_POPUP_VAR in request.GET:
            return [] # list!

This can lead to problems when you extend that method and expect a dict, and treat its return value as such trying to modify its elements. My patch returns an empty SortedDict.

Attachments (1)

fix_get_actions.diff (433 bytes) - added by philomat 6 years ago.

Download all attachments as: .zip

Change History (3)

Changed 6 years ago by philomat

Attachment: fix_get_actions.diff added

comment:1 Changed 6 years ago by Alex Gaynor

Resolution: fixed
Status: newclosed

In [15393]:

Fixed #15212 -- ensure that ModelAdmin.get_actions still returns a SortedDict if there are no actions.

comment:2 Changed 6 years ago by Alex Gaynor

In [15394]:

[1.2.X] Fixed #15212 -- ensure that ModelAdmin.get_actions still returns a SortedDict if there are no actions. Backport of [15393].

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