Perform action on model delete

Oct 08, 2013 · Updated: Jul 12, 2021 · by Tim Kamanin

Surprise, surprise, when you want to perform some actions on model delete, overriding delete() method may be not enough, because when you do bulk delete of models via admin interface it won't touch model's delete() method. The way out of it is using signals:

@receiver(post_delete, sender=Model)
def model_delete(sender, instance, **kwargs):
    # Do your on delete action here.

Hey, if you've found this useful, please share the post to help other folks find it:

There's even more:

Subscribe for updates

  • via Twitter: @timonweb
  • old school RSS:
  • or evergreen email ↓ ↓ ↓