Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7406981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:38:21+00:00 2026-05-29T05:38:21+00:00

I set up my model in MongoEngine, and try to query it (I already

  • 0

I set up my model in MongoEngine, and try to query it (I already have a few dozen documents in my collection), but the queryset is empty:

>>> mymodel.objects
[]

I can add new documents, and those show up in subsequent queries, but there’s sign of my preexisting documents:

>>> thingy = mymodel(a=2, b=3)
>>> thingy.save()
>>> mymodel.objects
[<mymodel: mymodel object>]

What gives? For reference, here’s my model definition:

from django.conf import settings
from mongoengine import *

connect(settings.MONGO_DATABASE, 
        host=settings.MONGO_HOST, port=settings.MONGO_PORT)

class metadata(Document):

    meta = {'collection': 'metadata'}

    _id   = StringField()
    name  = StringField()
    _type = StringField()
    terms = ListField()
    level = StringField()
    abbreviation  = StringField()
    latest_update = DateTimeField()
    feature_flags = ListField()
    session_details  = DictField()
    legislature_name = StringField()
    lower_chamber_name = StringField()
    upper_chamber_term = IntField()
    upper_chamber_name = StringField()
    lower_chamber_term = IntField()
    lower_chamber_title = StringField()
    upper_chamber_title = StringField()
    _ignored_scraped_sessions = ListField()

In case this question gets answered by the author of MongoEngine himself, I wish to express in advance that YOU ARE AWESOME!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T05:38:22+00:00Added an answer on May 29, 2026 at 5:38 am

    Nevermind, the docs answer my question:

    To use MongoEngine with existing data, you have to set allow_inheritance = False in you model definition, because MongoEngine’s inheritance tools set additional attributes on your documents (_cls and _types) and then (evidently) use them to filter MongoEngine queries. The other option may be to add those attributes onto existing documents.

    http://docs.mongoengine.org/guide/defining-documents.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the whole MVC-Model set up and use HTML views as templates. But
As described in another question , I have a set of Model objects and
Lets say I have model inheritance set up in the way defined below. class
I have set up a Core Data model where I have two objects, say
I currently have a model set up like so: I have a Test class
I have hierarchical data in a nested set model (table:projects): My table (projects): id,
How do you query a nested set model with multiple roots, such trees in
I have a series of UITableViewCell elements with various UIControls to set model values.
I've been using the crap out of the Nested Set Model lately. I have
Okay, basically, I have formed a mySQL query which returns a data set all

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.