[Fixed]-Serializer.is_valid() is always False

1👍

You dont have to convert a dictionary to string when using requests library’s json option. This should work:

import requests

data = {'login': 'mylogin', 'password': 'mypassword', 'mail': 'mymail'}
r = requests.post('http://127.0.0.1:8000/register_new_user', json=data)
👤v1k45

0👍

The solution is to use ast.literal_eval(request.data) to convert the string to a dictionary. I use request.data instead of manually parsing request.body.

However, v1k45’s answer is the best solution, as I do not need to convert my dict to a string before sending my request.

Leave a comment