-
-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] TypeError: can not serialize 'UUID' object models with pk type uuid #154
Comments
I think I actually have a similar issue, but with a different In my case, I set the {
"errors": [],
"data": "{\"test\": \"test\"}",
"action": "list",
"response_status": 200,
"request_id": "12345"
} This is of course also not the expected behavior... That's why I investigated a little and tried setting As I tested a little more with an explicit This might therefore need another test and special handling like the one introduced in #155, correct? |
@pollitux If I understand your problem well, it seems to me that it comes from the serialization. msgpack works only with primitive types. You can try with another serialization library. Personally I use orjson. class MyModelConsumer(ObserverModelInstanceMixin, GenericAsyncAPIConsumer):
queryset = MyModel.objects.all()
serializer_class = MyModelSerializer
@classmethod
async def decode_json(cls, text_data):
return orjson.loads(text_data)
@classmethod
async def encode_json(cls, content):
return orjson.dumps(content).decode() |
Describe the bug
When looking at a model and it has a pk type UUID it causes the exception
TypeError: can not serialize 'UUID' object
in chanels redisLOG
Additional context
This is my code that I use to observe the model with pk type UUID
I solved it by checking if the pk value of the model is a UUID type and convert it to a string
The text was updated successfully, but these errors were encountered: