Prior to version 0.8, MongoEngine defaults to storing DBRef. For 0.8 and later, it saves the ObjectId by default.
There is a dbref parameter that should be used when creating a ReferenceField ( explicit is better than implicit ):
class Bar(Document): content = StringField() foo = ReferenceField('Foo', dbref = True)
Here is the documentation for ReferenceField .
I have version 0.7.9 installed, and when I create a ReferenceField without the dbref parameter, I get the following warning:
[...]/lib/python2.7/site-packages/mongoengine/fields.py:744: FutureWarning: ReferenceFields will default to using ObjectId strings in 0.8, set DBRef=True if this isn't desired warnings.warn(msg, FutureWarning)
Miniquark
source share