Skip to content
This repository has been archived by the owner on Oct 19, 2022. It is now read-only.

mongoengine.errors.FieldDoesNotExist: The fields do not exist on the document #50

Open
Pacheco95 opened this issue Nov 11, 2021 · 0 comments

Comments

@Pacheco95
Copy link

Why this isn't working? If I change EnumField to be StringField it works, so the problem probably is marshmallow_enum

from enum import Enum
from marshmallow_enum import EnumField
from mongoengine import Document


class MyEnum(Enum):
    ENUM_VAL = "ENUM_VAL"


class MyModel(Document):
    type = EnumField(MyEnum, required=True)


MyModel(type=MyEnum.ENUM_VAL)
Traceback (most recent call last):
  File "<redatcted>/test.py", line 14, in <module>
    MyModel(type=MyEnum.ENUM_VAL)
  File "<redatcted>/venv/lib/python3.8/site-packages/mongoengine/base/document.py", line 92, in __init__
    raise FieldDoesNotExist(msg)
mongoengine.errors.FieldDoesNotExist: The fields "{'type'}" do not exist on the document "MyModel"
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant