Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

615
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!