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"
inputtxt=request.POST.get("getrow")
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.
To display POST values in django you can do:
print(list(request.POST.items()))
You can also also use dict()
print(dict(request.POST.items()))
Try use this:
def demoform(request):
if request.method=="POST":
inputtxt=request.POST['getrow']
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With