0
這裏是我的模型:無法追加EmbeddedDocument上的保存()
class Subscriber(Document):
service = StringField()
history = EmbeddedDocumentListField('SubscriberHistory')
def __str__(self):
return self.service
class SubscriberHistory(EmbeddedDocument):
action = StringField()
content = DictField()
created_at = DateTimeField(required=True, default=datetime.utcnow)
def __str__(self):
return self.action
和這裏的代碼,在那裏我試圖將嵌入保存到我的文檔:只要
subscriber_history = SubscriberHistory()
subscriber_history.action = 'inbound',
subscriber_history.content = event
self.subscriber.history.append(subscriber_history)
self.subscriber.save()
我跑self.subscriber.save()
我得到以下錯誤:
File "/foo/bar/env/lib/python3.5/site-packages/mongoengine/base/fields.py", line 415, in validate
self.error('Invalid %s item (%s)' % (field_class, value),
TypeError: __repr__ returned non-string (type tuple)
我的代碼是正確的(我在mongoengine文檔讀取),但它贏得了沒有工作。有任何想法嗎?