10👍
✅
Based on your Postman screenshot, you’re sending a list (denoted by []
).
"billing_details": [
{
"user":34,
"first_name":"Mylo",
"last_name":"Don"
}
]
If you remove the brackets so your POST request contains a dictionary (denoted by {}
) then you shouldn’t see this error anymore.
"billing_details": {
"user":34,
"first_name":"Mylo",
"last_name":"Don"
}
If you would like to be able to send multiple requests to billing_details
at a time then you can update your serializers.py
like so:
class OrderSerializer(serializers.ModelSerializer):
billing_details = BillingDetailsSerializer(many=True)
This will also make your original POST request work since passing the many=True
parameter causes the serializer to expect a list, in this case it will be a list of length 1.
- [Django]-Django admin upload and image to s3 and then resize the image and save a thumb problem
- [Django]-Celery 4.0.0 and Class based task workflow
- [Django]-Getting Django channel access in Celery task
Source:stackexchange.com