def get_inline_actions(self, request, obj=None):
"""
Returns a list of all actions for this Admin.
"""
# If self.actions is explicitly set to None that means that we don't
# want *any* actions enabled on this page.
if self.inline_actions is None:
return []
actions = []
# Gather actions from the inline admin and all parent classes,
# starting with self and working back up.
for klass in self.__class__.mro()[::-1]:
class_actions = getattr(klass, 'inline_actions', [])
# Avoid trying to iterate over None
if not class_actions:
continue
for action in class_actions:
if action not in actions:
actions.append(action)
return actions
评论列表
文章目录