i am working on this code:
poll_list = poll.object.all()
result = []
for q in poll_list:
result = result.append(q)
return HttpResponse(result)
it gives error of locAL VARS…any body knows the problem in this??
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.
result = result.append(q)is definitely not what you want as the call toappendreturnsNoneand you assign it toresultand after that you can’t access your list any longer viaresult. It has to beresult.append(q)which appendsqinto the mutable list.