I'm trying to create a nested object with a foreign key relation.
Relevant models
I'll illustrate the error on the models Phone and Student from the testapp
Relevant serializers
class NestedStudentSerializer(DynamicFieldsMixin, serializers.ModelSerializer):
class Meta:
model = Student
fields = '__all__'
class NestedPhoneSerializer(DynamicFieldsMixin, NestedModelSerializer):
student = NestedField(NestedStudentSerializer)
class Meta:
model = Phone
fields = '__all__'
Describe what you are trying to accomplish
I'm trying to create a nested object with a foreign key relation.
Relevant models
I'll illustrate the error on the models
Phone
andStudent
from thetestapp
Relevant serializers
Request body
What's the result?
Data that gets passed to the nested serializer is converted to the native representation and I get this error.
Versions django = "==2.2.24" djangorestframework = "==3.12.2"
I created a fork with a test here