Answer the question
In order to leave comments, you need to log in
What is the correct way to pass an HttpRequest to Tornado so that Django will correctly accept the QueryDict?
You need to correctly send an asynchronous POST request to django so that it correctly receives the data. So far, it gives me a QueryDict object:
Part of the code in tornado
http_client = httpclient.AsyncHTTPClient()
url = "http://127.0.0.1:8000/api/v0/thread/add/"
headers = {'Authorization': 'JWT ' + self.token}
context = {'thread':self.thread, 'message':self.message}
body = json.dumps(context)
print(body)
request = http_client.fetch(request=url, method="POST", headers=headers, body=context)
<QueryDict: {'{"thread": 1, "message": "09up9"}': ['']}>
{"thread": 1, "message": "09up9"}
Answer the question
In order to leave comments, you need to log in
From Tornado, the request was sent correctly. It's just that Django accepts the request body this way. With QueryDict, you can perform all the same operations that you perform with a regular dictionary. Optionally, you can cast it to a regular dictionary -d = query_dict.dict()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question