Home>

Help to extract the keys from the POST request. I send a request to Django from a third-party application and then I want to process it, but when I try to extract the keys, an empty dictionary is returned from me for some reason. the request itself is sending postmen http://127.0.0.1:8000/[email protected]

@csrf_exempt
def index (request):
    if request.method== 'POST':
        req= request.body.decode ('utf-8')
        print (f'The request itself received by {request} ')
        print (f 'request code {req}')
    return HttpResponse (0)

on prints outputs

The request itself received by < WSGIRequest: POST '/[email protected]'>decode request

What are the keys? {'email': '[email protected]'}, right?

nomnoms122021-02-23 12:12:50

yes, exactly what i need, but how did you get them?

Alex Ua2021-02-23 13:54:46

request.GET as in the response.

nomnoms122021-02-23 13:56:06
  • Answer # 1

    -parametersGET-query
    -optionsPOST-request

    That is, you need:

    request.GET
    request.POST