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 EnumField #20

Open
mk-dinamicka opened this issue Oct 18, 2022 · 1 comment
Open

Add support for EnumField #20

mk-dinamicka opened this issue Oct 18, 2022 · 1 comment

Comments

@mk-dinamicka
Copy link

Currently there is no support for EnumField that is mentioned in MongoEngine docs.

For now attempting to use this field like this raises an exception:

import mongoengine
from enum import Enum
from marshmallow_mongoengine import ModelSchema

class NotificationStyle(Enum):
    SUCCESS = "success"
    FAILURE = "failure"


class Notification(mongoengine.Document):
    style = mongoengine.EnumField(NotificationStyle, default=NotificationStyle.SUCCESS)

class NotificationListSchema(ModelSchema):
    class Meta:
        model = Notification
        model_skip_values = ()

marshmallow_mongoengine.exceptions.ModelConversionError: Could not find field of type <mongoengine.fields.EnumField object at 0x7fc05c3a3e80>.

Please add support for it.

@sponsfreixes
Copy link
Collaborator

@mk-dinamicka I was hoping to find time to tackle this, but it's proving difficult (not the fix, but finding time). Feel free to submit a PR with the fix for review, it will probably be quicker.

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

2 participants