奇怪的行为请求.POST在Djang

2024-07-01 07:59:20 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在通过邮递员向Django服务器发送一个POST请求。这就是我请求的主体

 POST /update/ HTTP/1.1
 Host: 127.0.0.1:8000
 Content-Type: multipart/form-data; boundary=----
 WebKitFormBoundary7MA4YWxkTrZu0gW
 Cache-Control: no-cache
 Postman-Token: 0764e56c-0fd8-fcce-5248-34f7d05f2748

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="UploadDownloadSettings"

dssssss
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="settings"; 
filename="settings.zip"
Content-Type: application/zip

当我试图访问request.POST['UploadDownloadSettings']时,程序说密钥无效。你知道吗

当我循环遍历request.POST中的键时,我从zip文件和键name中得到一堆键。你知道吗

根据文档,这应该解析出表单数据。据我所知,这似乎是标准格式的数据。你知道吗

https://docs.djangoproject.com/en/2.0/ref/request-response/#django.http.HttpRequest.POST

我是否误解了django post请求的工作方式?你知道吗

的输出请求.POST你知道吗

Key:
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition

Value:
form-data


Key:
name

Value:
"UploadDownloadSettings"


Key:
//actual filenames from the zip with their value

Value:
Blank

request.FILES的输出:空白映射

输出request.content_typeapplication/x-www-form-urlencoded


Tags: keynameformdatasettingsapplicationvaluerequest

热门问题