Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

617
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda