在分配后,字典成为MongoEngine中的BaseList

时间:2015-06-01 18:17:24

标签: python dictionary mongoengine

我使用的是mongoengine 0.9.0

class EntityChange(Document):
    ...
    old_data = DictField()
    new_data = DictField()

我想将dict个对象保存到old_datanew_data

为什么分配后字段会变为BaseList

data = {u'int_id': 100500, u'_cls': 'BuildingKind', ...}
instance = EntityChange()
instance.new_data = data
# after that
# isinstance(instance, BaseList) is True
# isinstance(instance, BaseDict) is False
# instance.new_data == ['int_id', 'id', ...] is True. why?

1 个答案:

答案 0 :(得分:2)