Django request Post json

后端 未结 4 2060
孤独总比滥情好
孤独总比滥情好 2021-01-01 19:35

I try to test a view, I receive a json request from the IPad, the format is:

req = {\"custom_decks\": [
        {
            \"deck_name\": \"deck_test\",
          


        
4条回答
  •  伪装坚强ぢ
    2021-01-01 19:54

    You're posting JSON, which is not the same as form-encoded data. You need to get the value of request.body and deserialize it:

    data = json.loads(request.body)
    custom_decks = data['custom_decks']
    

提交回复
热议问题