Skip to content

How to Get all post data from a request in Django?

Is there any way get all the form names from a request in Django ?

<input type="text" name="getrow">

Html request

def demoform(request):
    if request.method=="POST"
       return HttpResponse(...)

in the above I can get only from the name I know, what I need is to get all names of the django request and later parse it and get data.



Try use this:

def demoform(request):
    if request.method=="POST":
        return HttpResponse(...)

But if you need print a dynamic POST data, for example send the slug of many products, (i made it 2 days ago “April 22, 2018”) you need try this:

for key, value in request.POST.items():
    print('Key: %s' % (key) ) 
    # print(f'Key: {key}') in Python >= 3.7
    print('Value %s' % (value) )
    # print(f'Value: {value}') in Python >= 3.7
9 People found this is helpful