Replies: 1 comment 2 replies
-
Yer is you will need to create a custom if you consider a regular related model eg class Classroom(models.Model):
school = models.ForeignKey(School, related_name='children')
... And you want to subscribe to a School and get notified whenever a classroom is added/removed then you can create a custom model observer that observes changes to For many to many relationships you may need to explicitly create the ManyToMany table in django https://docs.djangoproject.com/en/4.0/topics/db/models/#extra-fields-on-many-to-many-relationships then you can create a custom observer on that many to many table to track additions/removals of related objects. You could create a single subscribe action that subscribes to the model instance and to all of these relationships you will need to explicitly create these. Having the option on a ObserverModelInstanceMixin to also include all related objects might be a good idea but I do not think it should be default. Might be nice if you could add an Feature request issue to the repo to track this as a possible future feature with some details on how you would expect to customise this if at all. |
Beta Was this translation helpful? Give feedback.
-
I have a consumer that inherits from ObserverModelInstanceMixin. The model I'm subscribing to has several relations with other models, including many-to-many and many-to-one.
I would like to get notified when one of the related objects change, when the m2m relations are updated, and when a related object gets created or deleted.
Is there a way to subscribe to both a model and all of its relations?
Beta Was this translation helpful? Give feedback.
All reactions