Skip to content

Commit

Permalink
Convert dispatch_uid to string in signal connections.
Browse files Browse the repository at this point in the history
Using `str(id(self))` for `dispatch_uid` ensures compatibility with cases where signal identifiers are expected to be strings. This change prevents potential issues in environments that enforce strict type checks.
  • Loading branch information
tumblingman committed Dec 13, 2024
1 parent 78cbf19 commit c4949c7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions djangochannelsrestframework/observer/model_observer.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ def _connect(self):

# this is used to capture the current state for the model
post_init.connect(
self.post_init_receiver, sender=self.model_cls, dispatch_uid=id(self)
self.post_init_receiver, sender=self.model_cls, dispatch_uid=str(id(self))
)

post_save.connect(
self.post_save_receiver, sender=self.model_cls, dispatch_uid=id(self)
self.post_save_receiver, sender=self.model_cls, dispatch_uid=str(id(self))
)

for field in self.model_cls._meta.many_to_many:
Expand All @@ -76,7 +76,7 @@ def _connect(self):
)

post_delete.connect(
self.post_delete_receiver, sender=self.model_cls, dispatch_uid=id(self)
self.post_delete_receiver, sender=self.model_cls, dispatch_uid=str(id(self))
)

def post_init_receiver(self, instance: Model, **kwargs):
Expand Down

0 comments on commit c4949c7

Please sign in to comment.