Skip to content
This repository was archived by the owner on Oct 19, 2022. It is now read-only.
This repository was 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

Description

@Pacheco95

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"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions