Hi, Is this still working for you on the latest version of DRF?
I'm trying to do the same, with almost an identical implementation (put instead of patch), but DRF ends up calling exclude_current_instance() on the queryset instead of a single object. The same issue is documented here: https://github.com/miki725/django-rest-framework-bulk/issues/68 That issue proposes copying to_internal_value() to a new class and inserting a few lines of code. On Wednesday, July 25, 2018 at 1:17:03 AM UTC-7, hiroko matsumoto wrote: > > This matter had been resolved by myself. > Thank you for showing my question! > > ``` > class PostsViewSet(viewsets.ModelViewSet): > queryset = Posts.objects.all() > serializer_class = PostsSerializer > filter_class = PostsFilter > ordering_fields = ('created_at') > > @action(methods=['patch'], detail=False) > def multi_update(self, request, *args, **kwargs): > queryset = self.filter_queryset(self.get_queryset()) > serializer = self.get_serializer(instance=queryset, > data=request.data, many=True, partial=True) # add "partial=True" > valid = serializer.is_valid(raise_exception=True) > logger.error(serializer.validated_data) > self.perform_update(serializer) > return Response(serializer.data) > ``` > > 2018-07-17 14:09 GMT+09:00 <[email protected] <javascript:>>: > >> I want to conduct bulk update for Model. >> I know "PUT" action can be called by specific data. So we must set a new >> action for the one. >> This is my source code of bulk update. >> https://github.com/encode/django-rest-framework/issues/6087 >> But, it couldn't work. >> Because "validated_data" was empty even though I couldn't use the >> parameter of read-only. >> I think my source code is incorrect especially creating serializer for >> ListSerializer. >> >> Please let me know and give me your advice if you have a nice idea. >> Thanks. >> >> > -- You received this message because you are subscribed to the Google Groups "Django REST framework" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
