I have a serializer like this:
class Serializer(serializers.ModelSerializer):
main_field = ListField(child=serializers.CharField(), required=True)
class Meta:
model = Model
fields = (
"main_field",
"field_a",
"field_b",
"field_c",
)
def update(instance, validated_data):
data = deepcopy(validated_data)
instance.filter(main_field=data.pop("main_field")).update(**data)
return validated_data
The thing is that when i update, then i call this return on my view:
return Response(status=status.HTTP_200_OK, data=serializer.data)
that's when serializer.data fails to be called because it was expecting all the fields, not just the partial ones.
logic: When i update i have to update all the fields on the rows called by the main_field list. So all of them should be grouped by the main_field list with the same other fields.
im using django 1.11 (can not do anything about that tbh).
Can't install any library neither, only DRF (project is too big, and have to ask permission for any library installed, already asked to use pandas, couldn't).