Last active
May 13, 2020 14:00
-
-
Save cansadadeserfeliz/9f98e8c743927d9b680d to your computer and use it in GitHub Desktop.
Django: how to remove delete action/button from admin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyAdmin(admin.ModelAdmin): | |
def has_delete_permission(self, request, obj=None): | |
return False | |
def get_actions(self, request): | |
actions = super(MyAdmin, self).get_actions(request) | |
if 'delete_selected' in actions: | |
del actions['delete_selected'] | |
return actions |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
it works