From 64cf570ad1ebda59f91e8db3c4235df33a064ace Mon Sep 17 00:00:00 2001 From: pollitux Date: Sun, 11 Sep 2022 09:03:56 -0500 Subject: [PATCH] Check if the pk of the model is type uuid and convert it to a str closes #154 --- djangochannelsrestframework/observer/model_observer.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/djangochannelsrestframework/observer/model_observer.py b/djangochannelsrestframework/observer/model_observer.py index d9bd7c5..4222f64 100644 --- a/djangochannelsrestframework/observer/model_observer.py +++ b/djangochannelsrestframework/observer/model_observer.py @@ -182,6 +182,10 @@ def serialize(self, instance, action, **kwargs) -> Dict[str, Any]: else: message_body["pk"] = instance.pk + # Check if the pk of the model is UUID type and convert it to a string + if isinstance(message_body['pk'], UUID): + message_body.update({'pk': str(message_body['pk'])}) + message = dict( type=self.func.__name__.replace("_", "."), body=message_body,