-
Notifications
You must be signed in to change notification settings - Fork 33
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
how serialize django model to gRPC message? #7
Comments
Hi Stan, |
I apologize for the late response! I wanted to have universal solution for converting model instance to protobuf. But I don't even remember how it worked because never used it :( I found a better approach by defining
Then in the servicer I can reuse that every time Page message must be returned. Regards, |
Thanks a lot, Stan, this looks reasonable. I will try it (hopefully) tonight. Cheers, mark |
Hi Stan, I started to implement your suggestion, but ran into some issues: |
You have to do that manually and copy model properties to protobuf structure like this:
This is especially true if your django models differ from protobuf |
Thanks, Stan, |
It depends on your protobuf structure. There can be one category per page or multiple, they can be defined as repeated strings or separate structures. Ideally, there would be Category.to_protobuf() so it could be called in Page.to_prptobuf() |
Hi Stan , Can you please add an example how to use it? Thank you |
same confuse here |
"There is an easy way to serialize django model to gRPC message using django_grpc.serializers.serialize_model."
i was reading the code trying to understand but i can't, do you have an example code of this?
thanks.
The text was updated successfully, but these errors were encountered: