Is there any way get all the form names from a request in Django ?
JavaScript
x
2
1
<input type="text" name="getrow">
2
Html request
JavaScript
1
5
1
def demoform(request):
2
if request.method=="POST"
3
inputtxt=request.POST.get("getrow")
4
return HttpResponse( )
5
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.
Advertisement
Answer
Try use this:
JavaScript
1
5
1
def demoform(request):
2
if request.method=="POST":
3
inputtxt=request.POST['getrow']
4
return HttpResponse( )
5
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:
JavaScript
1
6
1
for key, value in request.POST.items():
2
print('Key: %s' % (key) )
3
# print(f'Key: {key}') in Python >= 3.7
4
print('Value %s' % (value) )
5
# print(f'Value: {value}') in Python >= 3.7
6