When I am calling is_valid on my serializer, some of the data passed to the serializer is not getting saved. The files field is available in the serializer.initial_data, but does not get saved in serializer.validated_data. Any ideas?
Serializer:
class SomeSerializer(serializers.Serializer):
email = serializers.EmailField()
files = serializers.ListField(
child=serializers.FileField()
)
And the following view:
class SomeView(mixins.CreateModelMixin, generics.GenericAPIView):
permission_classes = (permissions.IsAuthenticated,)
serializer_class = SomeSerializer
def post(self, request, *args, **kwargs):
serializer = self.get_serializer(data=request.data)
serializer.is_valid(raise_exception=True)
email = serializer.validated_data["email"]
files = serializer.validated_data.get("files")
#Do something here
return response
read_onlyinSomeSerializer. - themanatufCharFields). No field in the serializer is markedread_only- Ankur GuptaFileFieldserializer before, so I'm not sure what else to suggest other than DRF thinks the list contents offilesaren't really files. - themanatufdata[files[index]]format in this case, I was sending it asdata[files] = [<InMemoryObject1>,<InMemoryObject2>,<InMemoryObject3> ]- Ankur Gupta