Django post_save signal on parent class with multi-table inheritance

18 Feb ยท by Tim Kamanin ยท 1 min read

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

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

Want to get more ๐Ÿ”ฅ tips like this one?

Subscribe to get notified about new dev tutorials