简体   繁体   English

request.POST未在Django接收

[英]request.POST not being picked up in django

I am using apiary to send API calls via POST. 我正在使用apiary通过POST发送API调用。 The method being sent is POST and it's sending the corret POST DATA , but django is not picking it up in the request.POST dict: 正在发送的方法是POST ,并且正在发送正确的POST DATA ,但是django没有在request.POST

# this is printing request.method, request.body
[remote IP:43306] POST b'{\\n    "email": "tomas@gmail.com",\\n    "password": "hellopassword"\\n}'

# this is printing request.POST
[pid 4974:tid 140607472903936] [remote 54.81.191.72:43306] 333 POST <QueryDict: {}>

Why can't django properly parse the POST data here? 为什么django无法在此处正确解析POST数据?

Check request.data instead. 而是检查request.data。

request.POST is normally only present when posting a form. request.POST通常仅在发布表单时出现。 Technically, it's only present when the content type header is form encoded eg 'multipart/form-data' 从技术上讲,仅当内容类型标头采用表单编码时才存在,例如“ multipart / form-data”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM