Reputation: 327
Is there a way that become aware of name and value of inputs in request.POST? I know i can access the value of inputs by knowing name of them like this:
name = request.POST['inputName']
but if i don't know how many inputs and with what names they are, what can i do? is there a way to loop through request.POST? (i create my html with xsl, and because i'm creating html by parsing xml file, the number and nmame of inputs are variable. so i have to use this way) really thanks for your help :)
Upvotes: 4
Views: 1461
Reputation: 174692
The default iterator of Python dictionaries returns keys - what this means is that when you loop through a dictionary, it will return each key. Since request.POST
is a "dict like" object, it works:
for i in request.POST:
print 'I have been passed the following keys: ',i
You can also do:
print 'The total number of keys in my POST request: ', len(request.POST.keys())
Upvotes: 8
Reputation: 1
Try to just foreach them. Example:
foreach(request.POST as item){
print item;
}
Upvotes: -3