How can you loop through the HttpRequest post variables in Django?
I have
for k,v in request.POST:
print k,v
which is not working properly.
Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
request.POSTis a dictionary-like object containing all given HTTP POST parameters.When you loop through
request.POST, you only get the keys.To retrieve the keys and values together, use the
itemsmethod.Note that
request.POSTcan contain multiple items for each key. If you are expecting multiple items for each key, you can uselists, which returns all values as a list.For more information see the Django docs for
QueryDict.