【问题标题】:request.POST.get() gives None in djangorequest.POST.get() 在 Django 中给出 None
【发布时间】:2016-06-30 09:03:14
【问题描述】:

我有一个 ajax 调用,我使用 pdb 捕获了请求。 request.POST 给了我以下值:

<QueryDict: {u'{"layer_id":1,"status":"True"}': [u'']}>

但是 request.POST.get('status') 给出 None

【问题讨论】:

    标签: python ajax django python-requests


    【解决方案1】:

    你没有发送表单编码的数据,所以request.POST 没用。使用request.body

    【讨论】:

    • 但 request.body 是一个字符串 @Daniel
    • 是的,它是一个 JSON 字符串。所以使用json.loads()
    猜你喜欢
    • 2022-07-06
    • 1970-01-01
    • 2020-08-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多