[Answered ]-Custom Django 'delete' action not firing from admin list view

1👍

delete selected is a bulk action and for efficiency reasons Django deletes the whole queryset at once, not calling the delete() method on each model instance.

If you need to make sure it does get called, e.g. you have some custom handling there that should not be skipped, just override the delete_queryset method on your ModelAdmin subclass like this:

# content of admin.py in your Django app

from django.contrib import admin

class MyModelAdmin(admin.ModelAdmin):
    def delete_queryset(self, request, queryset):
        for obj in queryset.all():
            obj.delete()

0👍

See @Brian Destura’s answer in the comments above.

Leave a comment