Best way to query a DictField in MongoEngine

mongoengine

Solution

You have wrong request, because you miss `someID`.

See you structure in db:

>>> db.note.findOne()
>>> {
    "_id": ObjectId("'0'*24")
    "someData": {
        "someID": {
            {"name": "Steve", "age":25}
        }
    }
}

So right request will be `Note.objects(someData__someID__name="Steve")`.

Problem

I've been hunting through the mongoengine documentation and around stack overflow and there doesn't seem to be a very clear answer to this so I'm asking: how do you best query a DictField? example code: ``` class Note(Document): someData = DictField() note = Note() note.someData['someID'] = {"name": "Steve", "age":25} note.save() ``` The closest I could find in the docs would be: ``` Note.objects(someData__name="Steve") ``` but that hasn't been working Again, feel like this should be a simple answer. Thanks for your help

Original source