How to modify default admin action "delete_selected"
Action docs
delete selected:
If you wish to override this behavior, simply write a custom action which accomplishes deletion in your preferred manner – for example, by calling Model.delete() for each of the selected items.
This discussion
has an example of overriding 'delete_selected' for a model. It could be implemented like this:
class SomeModelAdmin(admin.ModelAdmin):
actions = ['custom_delete_selected']
def custom_delete_selected(self, request, queryset):
#custom delete code
custom_delete_selected.short_description = "Delete selected items"
def get_actions(self, request):
actions = super(SomeModelAdmin, self).get_actions(request)
del actions['delete_selected']
return actions
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With