Reputation: 786
I use python requests.post function to send json queries to my django app.
r = requests.post(EXTERNAL_SERVER_ADDRESS, data={'123':'456', '456':'789'})
But on the external server request.POST object looks like this:
<QueryDict: {'123': ['456'], '456': ['789']}>
Why does it happen? How can I just send a dict?
Upvotes: 0
Views: 453
Reputation: 1461
You are sending a dict, Django transform this JSON in this QueryDict objetc automatically when it receives the message. If you want to parse it to an dict, do:
myDict = dict(queryDict.iterlists())
Upvotes: 1
Reputation: 599450
requests is not doing anything here. Presumably your receiving server is Django; that's just how it represents data from a request. request.POST['123']
would still give '456'.
Upvotes: 1