8π
β
The error is coming from signup view at line data = json.loads(data)
.
In order to access the POST
data you can simply access it by using request.POST
:
data = request.POST
So remove these lines and replace with above line of code:
data = request.body
data = json.loads(data)
Or try (as figured out via discussion):
response = self.client.post('/signup/', json.dumps(my_data), content_type='application/json')
π€Aamir Rind
0π
if you get error for printing (using) response.json()
instead of response.json() use response.data
response = self.client.get(url, data)
print(response.json()) # if cause 'json.decoder.JSONDecodeError', use response.data
0π
I was also stuck with it. Use dict() instead of json.
data = dict(request.POST)['checkedbox']
result = list(map(int, data))
- [Django]-How to extend UserCreationForm with fields from UserProfile
- [Django]-Firing notifications at specific times in Django
- [Django]-Django handle newlines in textarea
Source:stackexchange.com