MultiValueDictKeyError while uploading file in django rest

I have a problem with a PUT request. It occurs when trying to access request.data['file'] views.py

class ImageAPIView(APIView):
    parser_class = [FileUploadParser]

    #def get(self, request):
    #    qry = Image.objects.all()
    #    serializer = DiagnosisSerializer(qry, many=True)
    #    return Response(serializer.data)

    def put(self, request, filename, format=None):
        f = request.data['file']

        return Response(status=204)

I do everything as in the documentation, but for some reason an error occurs.I searched almost the whole day on Google, and could not find the reason. I hope someone can help me

Вернуться на верх