Reputation: 21
Django test throws value error every time i try to input data in the test request
req_body = {"Value1":"Value1", "Value2":"Value2"}
request = self.client.get(self.getSingleData_url, data= json.dumps(req_body), content_type='application/json')
I have tried data = req_body but it returns an empty {} to the endpoint Complete Value error
I have tried using, other ways to pass data, but once it is passed as json it throws Value Error
Upvotes: 0
Views: 361
Reputation: 765
I was in the same problem. Setting up a breakpoint and inspecting the "request" object, I found out that, the data i.e req_body you're passing, can be found as:
dict(request.query_params)['Value1']
and similarly for Value2
.
hope this helps.
Upvotes: 0