Skip to content

Instantly share code, notes, and snippets.

@koddr
Forked from cansadadeserfeliz/admin.py
Created March 7, 2018 19:18
Show Gist options
  • Save koddr/7a9b8979a3b531d2837a57036ce06441 to your computer and use it in GitHub Desktop.
Save koddr/7a9b8979a3b531d2837a57036ce06441 to your computer and use it in GitHub Desktop.
Django: how to remove delete action/button from admin
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