DjangoDjango

Django post_save signal on parent class with multi-table inheritance

Feb 18, 2015 · Updated: Nov 07, 2017 · by Tim Kamanin

Entity is a parent class of polymorphic multi-table inheritance. We want to attach post_save signal to every child of this class.

python
# Propagate signal across all children of a polymorphic parent.
for subclass in Entity.__subclasses__():
    post_save.connect(delete_comments, sender=subclass)

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 ↓ ↓ ↓