26👍
✅
You should specify json as format:
response = self.client.post(cart_item_url, data=data, format='json')
2👍
You can try this
response = self.client.post(cart_item_url, json.dumps(data), content_type='application/json')
this is working for me
- Assigning blocktrans output to variable
- Django Haystack: filter query based on multiple items in a list.
1👍
Try specifying content_type
as application/json
.
response = self.client.post(cart_item_url, data=json.dumps(data), content_type='application/json')
- Handling HTTP chunked encoding with django
- Limiting the queryset for ManyToMany MultipleSelect in Django admin
- Celerybeat automatically disables periodic task
- Django WeasyPrint CSS integration warning: Relative URI reference without a base URI: <link href="/static/css/bootstrap.min.css"> at line None
0👍
Try:
response = self.client.post(cart_item_url, data=json.dumps(data)), headers={'Content-Type': 'application/json'})
Source:stackexchange.com