Snippet: Django post_save signal on parent class with multi-table inheritance

Entity is a parent class of polymorphic multi-table inheritance. We want to attach post_save signal to every child of this class.
1
2
3
  1. # Propagate signal across all children of a polymorphic parent.
  2. for subclass in Entity.__subclasses__():
  3. post_save.connect(delete_comments, sender=subclass)