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
ModelAdmin.get_actions returns the actions shown. By overriding this method, to remove
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
You should also read How to remove the ‘Add’/’Delete’ button for a model?.