4

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?

Preston
  • 7,399
  • 8
  • 54
  • 84

1 Answers1

1

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'
Preston
  • 7,399
  • 8
  • 54
  • 84