Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

616
Vistas
Mongoengine: mongoengine.errors.FieldDoesNotExist

I've been confused with this error. I'm creating a Vehicle database with mongoengine that goes like this.

class Vehicles(Document):
    make: StringField()
    model: StringField()
    license: StringField()
    year: IntField()
    mileage: IntField()
    deleted: BooleanField()

for j in range(2):
    vehicle = Vehicles(
        make="Honda",
        model="Civic",
        license="H54 " + str(i) + str(j),
        year=2015,
        mileage= 500 + (i * 500),
        deleted=False
    ).save()

While I try running the code, I've been getting:

mongoengine.errors.FieldDoesNotExist: The fields "{'license', 'year', 'model', 'mileage', 'make', 'deleted'}" do not exist on the document "Vehicles"

I don't understand why it's giving me this error. I know a solution is to change Document into DynamicDocument, but I don't really see why. Can someone please explain to me this error???

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You are writing your class as if it was a dataclass but Mongoengine has no support for type hinting so it is not intepreting that correctly. MongoEngine is in fact currently not seeing any of your field definitions.

Turn your ":" into "=" and it should be fine

class Vehicles(Document):
    make = StringField()    # instead of 'make : StringField()'
    ...
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda