How force requests post xml to django's request.FILES but not request.POST?
I'm using requests to post xml file to django 1.7b4, seems requests would try convert file content to string, if convert successfully then post it to request.POST, or failed to requist.FILES. but, how force it always post to request.FILES?
Here is my code:
f = open(full_name, 'rb')
files = {'file': f}
res = requests.post(url, files=files, data={'filename':filename})
f.close()
and ugly view function:
if 'file' in request.FILES:
log_tree = etree.parse(request.FILES['file'])
elif 'file' in request.POST:
log_tree = etree.fromstring(request.POST['file'])
THX!
链接地址: http://www.djcxy.com/p/56558.html