0

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)>}

1 Answer 1

1

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'}
Sign up to request clarification or add additional context in comments.

1 Comment

it worked, thank You. Can you remove mentioned emails from your answer.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.