Py学习  »  Django

Django文件上载中的/files/处出现多值dictkeyerror

Jibin Mathew • 4 年前 • 149 次点击  

使用django rest框架上传文件时遇到问题。 我正在使用postman进行测试,并将内容类型header添加为多部分/表单数据,但是

多值dictkeyerror at/files/error,这是我的代码。

class FileUploadView(APIView):
    parser_classes = (MultiPartParser,)

    def put(self,request, format = None):

        file_obj = request.FILES['file']

        file_obj.seek(0)
        data = file_obj.read()

        return Response(data,status=204)

我使用多部分表单数据,以便在上载文件的同时访问post数据。

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/40265
 
149 次点击  
文章 [ 1 ]  |  最新文章 4 年前
Jibin Mathew
Reply   •   1 楼
Jibin Mathew    5 年前

我在postman中从头中删除了多部分/表单数据,api工作了