Skip to content

Add support for Enums to be used on a model's polymorphic identity on PolymorphicModelSerializer #46

@lucasvbleite

Description

@lucasvbleite

Right now, if a model has a polymorphic_identity as an Enum, they keys of the sub_serializers are a dict who's keys are enums, so
self.sub_serializers.get(model_identity) returns None because model_identity is a string

    def load(self, serialized, existing_model=None, session=None):
        if self.is_polymorphic:
            model_identity = serialized.get(self.identity_key)
            if model_identity and self.sub_serializers.get(model_identity):
                return self.sub_serializers[model_identity].load(
                    serialized, existing_model, session
                )
        return super().load(serialized, existing_model, session)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions