I want to partially-update multiple items at once. I've already added a mixin for allowing me to bulk-create (and that works well) but even though I've added a partial argument, it doesn't allow for patching a list.
I'm guessing that this is a routing issue. I need a new view to handle PATCH on / (rather than /id/), but I'm well out of my depth.
Existing answers for this don't work for 3.8, or at least haven't worked for me. What do I need to do to the following?
class ResourceSerializer(serializers.ModelSerializer):
class Meta:
model = Resource
fields = ('id', 'name', ...)
read_only_fields = ('id',)
class BulkMixin:
def get_serializer(self, *args, **kwargs):
if isinstance(kwargs.get('data', {}), list):
kwargs['many'] = True
kwargs['partial'] = True
return super().get_serializer(*args, **kwargs)
class ResourceViewSet(BulkMixin, viewsets.ModelViewSet):
serializer_class = ResourceSerializer