-
Notifications
You must be signed in to change notification settings - Fork 25
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-to: Mulitple Objects Serialisation - bulk creation of a list of objects ? #259
Comments
Hi, class BulkCreateMixin:
@grpc_action(
request=SelfSerializer,
use_request_list=True,
response=SelfSerializer,
use_response_list=True
)
async def BulkCreate(self, request, context):
serializer = await self.aget_serializer(message=request, many=True)
await sync_to_async(serializer.is_valid)(raise_exception=True)
await self.aperform_create(serializer)
return await serializer.amessage
async def perform_bulk_create(self, serializer):
await serializer.asave() |
Merci, @legau, |
btw. @legau, |
Hello @markdoerr You may want to look at this issue: and this documentation: https://django-socio-grpc.readthedocs.io/en/stable/features/grpc-action.html#use-request-and-response-list Also the gRPC size limits is configurable in https://django-socio-grpc.readthedocs.io/en/stable/settings.html#server-options |
Thanks, @AMontagu , |
If I remember correctly the main issue is that bigger message will have impact on your network flow and may increase delay on all your API. But not sure of me. |
I was lately trying to implement a multi / bulk create Service, similar as described at the DRF.
Simple ideas failed, like adding many=True to the class Meta.
https://www.django-rest-framework.org/api-guide/serializers/#dealing-with-multiple-objects
Does DSG support the (bulk) generation of multiple objects, like providing a list of objects to the Create Method ?
What is the best way to do that ? Using streams ?
I would include it into the DSG Example, once I have an idea.
Merci :)
The text was updated successfully, but these errors were encountered: