I’m submitting my form from postman. But i’m getting all key values as a list. I don’t know why, how can i get key values without list.
here is request.data i’m getting:
{'from_email': ['somemail@gmail.com'], 'to_email': ['somemailother@gmail.com'], 'subject': ['hey man whats up ?'], 'html_body': [<InMemoryUploadedFile: email_test_template.html (text/html)>]}
I’m expecting it to be like following.
{'from_email': 'somemail@gmail.com', 'to_email': 'somemailother@gmail.com', 'subject': 'hey man whats up ?', 'html_body': <InMemoryUploadedFile: email_test_template.html (text/html)>}
>Solution :
You can write simple loop over it,
response = {'from_email': ['a@gmail.com'], 'to_email': ['b@gmail.com'], 'subject': ['hey man whats up ?'], 'html_body': ['seom']}
dummy = dict()
for key, val in response.items():
dummy[key] = val[0]
print(dummy)
{'from_email': 'a@gmail.com', 'to_email': 'b@gmail.com', 'subject': 'hey man whats up ?', 'html_body': 'seom'}