Using a PATCH
request on a RetrieveUpdateDestroyAPIView
I receive the following in RetrieveUpdateDestroyAPIView.update
when i run print(request.data)
:
{'myVar': ''}
when running automated tests using django rest framework's APIClient I get this:
<QueryDict: {'myVar': ['']}>
Why is this different? What can i do to ensure consistency between my environments of test and dev?
You need to be explicit that you're passing json, you can do this by either:
response = self.client.patch(self.url, json={'myVar': ''})
Or:
response = self.client.patch(self.url, {'myVar': ''}, format='json') # added , format='json'