Saving data using Nested Serializers in Rest Framework

Here is my problem in great détails :

Is there a reason that the OrderSerializer has exams as read_only?

class OrderSerializer(serializers.ModelSerializer):
    exams = ExamSerializer(many=0,read_only=1)
    class Meta:
        model = Order
        fields = '__all__'

That’s likely why the order doesn’t get exams set when calling save leading to a NOT NULL constraint failure.

1 Like

Thanks, the problem is solved :white_check_mark: