3. How to remove the delete selected action in Django admin?

By default Django adds a Delete Selected action to the listview page. You have been asked to remove the action from the Hero admin.

The method ModelAdmin.get_actions returns the actions shown. By overriding this method, to remove delete_selected We can remove it form the dropdown. Your code looks like this with the changes.:

def get_actions(self, request):
    actions = super().get_actions(request)
    if 'delete_selected' in actions:
        del actions['delete_selected']
    return actions

And your admin looks like this

_images/export_selected.png

You should also read How to remove the ‘Add’/’Delete’ button for a model?.