我正在尝试更新mongoengine中嵌入文档的列表字段。我已经看过几乎所有相关的问题,但不知何故我的代码就是不起作用。我知道我少了一些小东西,但我想不出来。在
这是我的代码:
文件:
class Address(EmbeddedDocument):
line1 = StringField(required=True, max_length=63)
line2 = StringField(max_length=127)
pin = StringField(max_length=6, min_length=6)
class Store(EmbeddedDocument):
code = StringField(max_length=50, required=True)
store_name = StringField(max_length=255, required=True)
address = EmbeddedDocumentField(Address)
class Vendor(Document):
name = StringField(max_length=255, required=True)
stores = ListField(EmbeddedDocumentField(Store))
视图:
^{pr2}$以下是我打印报表的输出:
<QueryDict: {u'oper': [u'edit'], u'code': [u'BSK'], u'pin': [u'1'], u'line2': [u'near huda city center'], u'line1': [u'Shushant Lok'], u'store_name': [u'Baskin'], u'id': [u'2']}>
address new near huda city center 1
new store near huda city center 1
updated 0
我的更新存储方法不起作用。请帮忙。在
好吧,我现在可以用我的代码了。 我修改了我的update_store方法,它成功了。在
相关问题 更多 >
编程相关推荐