Dictionary 赋值后在 MongoEngine 中变为 BaseList
Dictionary becomes BaseList in MongoEngine after assignement
我正在使用 mongoengine 0.9.0
class EntityChange(Document):
...
old_data = DictField()
new_data = DictField()
我想将 dict
个对象保存到 old_data
和 new_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?
我正在使用 mongoengine 0.9.0
class EntityChange(Document):
...
old_data = DictField()
new_data = DictField()
我想将 dict
个对象保存到 old_data
和 new_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?