MongoEngineバージョン0.8より前では、デフォルトでDBRefが保存されます。0.8以降では、デフォルトでObjectIdを格納します。
dbref
ReferenceFieldを作成するときに使用する必要のあるパラメーターがあります(明示的は暗黙的よりも優れています):
class Bar(Document):
content = StringField()
foo = ReferenceField('Foo', dbref = True) # will use a DBRef
bar = ReferenceField('Bar', dbref = False) # will use an ObjectId
ReferenceFieldのドキュメントは次のとおりです。
バージョン0.7.9をインストールしましたが、パラメーターなしdbref
でReferenceFieldを作成すると、次の警告が表示されます。
[...]/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)