diff options
author | hashlash <muh.ashlah@gmail.com> | 2020-03-20 14:24:14 +0700 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2020-04-17 20:23:00 +0200 |
commit | dfbd9ca065728b543cc756359079a1b51d10841a (patch) | |
tree | 259d7fcfebd46968e5838c596f5ff8f68ebbbd8e /django/contrib/admin/options.py | |
parent | 75410228dfd16e49eb3c0ea30b59b4c0d2ea6b03 (diff) | |
download | django-dfbd9ca065728b543cc756359079a1b51d10841a.tar.gz |
Fixed #30311 -- Restored ability to override global admin actions.
Diffstat (limited to 'django/contrib/admin/options.py')
-rw-r--r-- | django/contrib/admin/options.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py index 2099d14861..2913107b9c 100644 --- a/django/contrib/admin/options.py +++ b/django/contrib/admin/options.py @@ -858,15 +858,20 @@ class ModelAdmin(BaseModelAdmin): def _get_base_actions(self): """Return the list of actions, prior to any request-based filtering.""" actions = [] + base_actions = (self.get_action(action) for action in self.actions or []) + # get_action might have returned None, so filter any of those out. + base_actions = [action for action in base_actions if action] + base_action_names = {name for _, name, _ in base_actions} # Gather actions from the admin site first for (name, func) in self.admin_site.actions: + if name in base_action_names: + continue description = getattr(func, 'short_description', name.replace('_', ' ')) actions.append((func, name, description)) # Add actions from this ModelAdmin. - actions.extend(self.get_action(action) for action in self.actions or []) - # get_action might have returned None, so filter any of those out. - return filter(None, actions) + actions.extend(base_actions) + return actions def _filter_actions_by_permissions(self, request, actions): """Filter out any actions that the user doesn't have access to.""" |