6

Im using DJango REST framework to write my web service layer in which I want to read request payload from the request (POST). I tried the following code but I get empty set

@api_view(['POST'])
def login(request):
    print request.POST

Content Type is JSON. I tried to pass data from REST Client Tool. Still am able to read header values but only Payload is not coming out.

4

1 回答 1

10

您应该使用request.DATA而不是request.POST检索 json 数据。

request.DATA自 3.0 版起已被弃用,request.data自 3.2 版起已完全删除。

于 2013-10-28T18:55:29.597 回答