Django code samples involving post data often shows code similar to this:
if request.method == "POST":
post = request.POST.copy()
#do stuff with post data
Is there a reason for copying the post data instead of working with it directly?
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.
I think it is because
request.POSTitself is defined immutable. If you want a version you can actually change (mutability), you need a copy of the data to work with.See this link (request.POST is a QueryDict instance).