﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
33977	Grouping action in the ModelAdmin	Willem Van Onsem	nobody	"One can make the action dropdown visually more pleasant by introducing groups. This does not require a lot of logic: we can easily update the `@action` decorator to allow specifying an `action_group`, and by slightly modifying the `get_action_choices` method, we can generate a list of groups that contain the actions:

{{{
diff --git a/django/contrib/admin/decorators.py b/django/contrib/admin/decorators.py
index d3ff56a59a..ad34df2e65 100644
--- a/django/contrib/admin/decorators.py
+++ b/django/contrib/admin/decorators.py
@@ -1,4 +1,4 @@
-def action(function=None, *, permissions=None, description=None):
+def action(function=None, *, permissions=None, description=None, group=None):
     """"""
     Conveniently add attributes to an action function::
 
@@ -23,6 +23,8 @@ def action(function=None, *, permissions=None, description=None):
             func.allowed_permissions = permissions
         if description is not None:
             func.short_description = description
+        if group is not None:
+            func.action_group = group
         return func
 
     if function is None:
diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
index 8ccacd6213..ca61901fe7 100644
--- a/django/contrib/admin/options.py
+++ b/django/contrib/admin/options.py
@@ -1,4 +1,5 @@
 import copy
+from collections import defaultdict
 import json
 import re
 from functools import partial, update_wrapper
@@ -1024,11 +1025,13 @@ class ModelAdmin(BaseModelAdmin):
         Return a list of choices for use in a form object.  Each choice is a
         tuple (name, description).
         """"""
+        choices = defaultdict(list)
+        choices[None].extend(default_choices)
         choices = [] + default_choices
         for func, name, description in self.get_actions(request).values():
             choice = (name, description % model_format_dict(self.opts))
-            choices.append(choice)
-        return choices
+            choices[getattr(func, 'action_group', None)].append(choice)
+        return list(choices.items())
 
     def get_action(self, action):
         """"""
}}}"	New feature	closed	contrib.admin	dev	Normal	duplicate			Unreviewed	1	0	0	0	1	0
