Issue
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': ['[email protected]'], 'to_email': ['[email protected]'], 'subject': ['hey man whats up ?'], 'html_body': [<InMemoryUploadedFile: email_test_template.html (text/html)>]}
I'm expecting it to be like following.
{'from_email': '[email protected]', 'to_email': '[email protected]', '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': ['[email protected]'], 'to_email': ['[email protected]'], 'subject': ['hey man whats up ?'], 'html_body': ['seom']}
dummy = dict()
for key, val in response.items():
dummy[key] = val[0]
print(dummy)
{'from_email': '[email protected]', 'to_email': '[email protected]', 'subject': 'hey man whats up ?', 'html_body': 'seom'}
Answered By - Nishant Nawarkhede
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.