PATCH and PUT don't work as expected when pytest is interacting with REST framework

rest_framework.exceptions.ParseError: JSON parse error - Expecting property name enclosed in double quotes: line 1 column 2 (char 1)`

This is usually sign that you send a string inside a string in json. For example:

resp = client.patch(self.url, data=json.dumps("name=123"), content_type='application/json')

will cause this kind of issues.

rest_framework.exceptions.UnsupportedMediaType: Unsupported media type "application/octet-stream" in request.

This means that the request has been sent as "application/octet-stream" which is Django's test default.

To ease the pain with dealing with all that, Django REST framework provides a client on its own: http://www.django-rest-framework.org/api-guide/testing/#apiclient

Note that the syntax is slightly different from Django's one and that you won't have to deal with json encoding.