0
我试图让我的django rest框架应用程序接受文件上传。上传文件应附带描述文件的附加数据,并且对于后期处理是必要的。上传文件似乎工作正常,但是,我似乎无法让django应用程序访问其他数据。例如,我有一个文件more_info.html
而我试图上传到我的应用程序:Python - 将文件发布到带有额外数据的Django
import requests
url = "http://www.example.com/fileupload"
files = {'file':open('more_info.html','rb')
data = {'brand':'my brand','type':'html','level':'dev'}
headers = {'Content-type': 'multipart/form-data', 'Content-Disposition': 'attachment; filename="more_info.html"'}
r = requests.post(url,files=files,data=,headers=headers)
在我的Django的看法,我想用下面查看我的POST数据:
def post(self, request):
print(request.POST)
print(request.FILEs)
两个打印语句正在返回:
{u'file': <InMemoryUploadedFile: more_info.html (multipart/form-data)>}
如何访问请求POST中的其余数据?