[英]must be convertible to a buffer, not QueryDict Django
i'm using Django rest_framework in the project that will accept a request which is in multipart/form-data and then have to forward the same request data to a new url. 我在项目中使用Django rest_framework,它将接受multipart / form-data中的请求,然后将相同的请求数据转发到新的url。
I used the MultiPart Parser using which I'm getting the request object. 我使用了MultiPart Parser,通过它我可以获取请求对象。
I'm sending a new request which has the body =request.data(QueryDict object) using httplib2 library. 我正在使用httplib2库发送包含正文= request.data(QueryDict对象)的新请求。 the QueryDict object looks like below:
QueryDict对象如下所示:
> <QueryDict: {u'input_values': [<InMemoryUploadedFile: inputs.json
> (application/octet-stream)>], u'app_template':
> [<InMemoryUploadedFile: app.zip (application/octet-stream)>]}>
How can I convert the QueryDict to a proper request body in order to forward the request with the attributes? 如何将QueryDict转换为适当的请求主体,以转发具有属性的请求?
Here's what I did: 这是我所做的:
import from poster multipart_encode
register_openers()
datagen,headers=multipart_encode(dict(request.FILES.iterlists()))
requestData="".join(datagen)
You can use the requestData as body to send the request. 您可以使用requestData作为正文来发送请求。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.