我刚刚升级了 mongoengine,现在我遇到了一个错误。目前,模型定义如下:
class Descriptor(Document):
root = ReferenceField(DescriptorNode, required=True)
(..)
class DescriptorNode(Document):
channel = ReferenceField(Channel, required=True)
(..)
class Channel(Document):
(..)
使用DBRef = True
,这是我与 mongoengine==0.7.10 一起使用的当前代码:
descriptor = Descriptor.objects.get(id = xxxx)
channel = descriptor.root.channel
我选择删除DBRef = True
以便迁移到 mongoengine==0.8.1 然后重建数据库。
现在我收到此错误:
channel = descriptor.root.channel
AttributeError: channel
/site-packages/bson/dbref.py Line:88
我试过select_related()
了,但似乎没有任何工作正常。
描述符:
{
"_id" : ObjectId("51ae3f6ba2aa1c0a32998952"),
"created_date" : ISODate("2013-06-04T19:26:35.630Z"),
"modified_date" : ISODate("2013-06-05T12:45:55.570Z"),
"sequence" : 843174,
"groups" : [ ],
"name" : "desktop-BR",
"root" : ObjectId("51ae3f6ba2aa1c0a329988b0"),
"tree_hash" : "97e3716db74543e66a11405e9e04185452183ac1"
}
描述符节点:
{
"_id" : ObjectId("51ae3f6aa2aa1c0a3299885a"),
"channel" : ObjectId("51ae0f06a2aa1c0a327f3958"),
"created_date" : ISODate("2013-06-04T19:26:34.235Z"),
"groups" : [ ],
"is_prioritized" : false,
"is_published" : true,
"modified_date" : ISODate("2013-06-05T12:46:02.704Z"),
"order" : 0,
"sequence" : 842926
}