在MongoEngine文檔類似乎並不具有「to_bson」功能:如何將MongoEngine文檔對象轉換爲BSON?
from mongoengine import *
class MyDoc(Document):
foo = StringField()
bar = IntField()
doc = MyDoc.objects.create(foo=u"Hello World")
print "Document BSON length is:", len(doc.to_bson()) # fails : no "to_bson"
任何解決方案?