Hello,
The test client is not converting the data to json.
1. In your test module, you must convert the data to json and tell the correct content-type application/json:
json_data = json.dumps({'active': False})
data =
self.client.post(path=url, data=json_data, content_type='application/json')
I notice that you use a format='json' parameter to post; I can't find anything about that parameter in the documentation or the code. You should use content_type='application/json' instead.
2. In the views module, you should parse the json data:
if request.method == 'POST':
body = request.body.decode('UTF-8')
json_data = json.loads(body)
print('views 12', json_data['active'])
Kindly note that you should be using request.body instead of the deprecated raw_post_data.
Regards,
Camilo