Open kabancheg opened 3 years ago
same issue, but it complains about .create()
class ContextPolymorphicSerializer(PolymorphicSerializer, serializers.ModelSerializer):
model_serializer_mapping = {
SimpleContext: SimpleContextSerializer,
TemplateContext: TemplateContextSerializer
}
class Meta:
model = SimpleContext
fields = '__all__'
It seems that the serializer needs to inherit serializers.ModelSerializer and have Meta class.
I still get an Incorrect type Error
rest_framework.exceptions.ValidationError: {'hierarchy': [ErrorDetail(string='Incorrect type. Expected pk value, received str.', code='incorrect_type')]}
And the hierarchy is not even of type str
it is dict
.
Can not update nested polymorphic object. I tried all methods (patch, put) but the drf exception occurs. I checked all issues/solutions and nothing helps. I've stucked on it for 2 weeks. Maybe I am doing wrong...
exception
data
requirements
serializers.py
models.py