Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
lucasvbleite opened this issue Apr 18, 2024 · 0 comments

Comments

@lucasvbleite
Copy link
Contributor

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant