我有Page
模型如下,page_id
字段不是unique
,但我无法从Page
创建实例,此错误会增加
OperationError: Could not save document (insertDocument :: caused by ::11000 E11000 duplicate key error index: shopify.page.$pageId_1 dup key: { : null })
当page_id
字段不是unique
时,我不知道为什么重复键错误会上升
Site
模型:
class Page(Document):
# page identity
page_id = StringField()
store = ReferenceField('Store')
is_product = BooleanField(default = False)
is_homepage = BooleanField(default = False)
product = ReferenceField('Product')
requests = ListField(EmbeddedDocumentField('Request'))
# page stat
visitors = IntField(default = 0)
views = IntField(default = 0)
past_days = ListField(EmbeddedDocumentField('DayStat'))
答案 0 :(得分:0)
是的,我还从field属性中删除了unique = True,然后删除了Collection并再次运行了代码。这样就解决了问题。