Skip to content

Commit

Permalink
Check if the pk of the model is type uuid and convert it to a str closes
Browse files Browse the repository at this point in the history
  • Loading branch information
pollitux committed Sep 11, 2022
1 parent 583e843 commit 64cf570
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions djangochannelsrestframework/observer/model_observer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 64cf570

Please sign in to comment.