If a PolymorphicSerializer is subclassed
PolymorphicSerializerMetaclass.__new__ raises an error because discriminator does not exist in attrs
def __new__(cls, name, bases, attrs):
attrs["discriminator"] = cls._sanitize_discriminator(name, attrs)
return super().__new__(cls, name, bases, attrs)
currently fixed this by copying the discriminator:
class RolSubSerializer(SubSerializerMixin, RolSerializer):
discriminator = RolSerializer.discriminator
Another issue is when the discriminatior has set the group_field, this field is added to all fields in the mapping in PolymorphicSerializerMetaclass.santize_discriminator, when the subclass (that copied the discriminator) is loaded this function is called again which results in <group_field><group_field>, this can currently be fixed by copying the mapping to the original serializer and the subserializer or by not setting group_field on the sub_serializer.
If a PolymorphicSerializer is subclassed
PolymorphicSerializerMetaclass.__new__raises an error becausediscriminatordoes not exist in attrscurrently fixed this by copying the discriminator:
Another issue is when the discriminatior has set the group_field, this field is added to all fields in the mapping in
PolymorphicSerializerMetaclass.santize_discriminator, when the subclass (that copied the discriminator) is loaded this function is called again which results in <group_field><group_field>, this can currently be fixed by copying the mapping to the original serializer and the subserializer or by not setting group_field on the sub_serializer.