Python 在Mongoengine中,如何拥有引用父文档类型的嵌入式文档^

Python 在Mongoengine中,如何拥有引用父文档类型的嵌入式文档^,python,mongodb,mongoengine,Python,Mongodb,Mongoengine,我正在使用Flask和Mongoengine开发Python API。我希望具有以下结构: class FactionRelationship (Document): faction = ReferenceField('Faction') relationship = IntField() class Faction (Document): name = StringField(required=True) relationships = ListField(E

我正在使用Flask和Mongoengine开发Python API。我希望具有以下结构:

class FactionRelationship (Document):
    faction = ReferenceField('Faction')
    relationship = IntField()

class Faction (Document):
    name = StringField(required=True)
    relationships = ListField(EmbeddedDocumentField(FactionRelationship))

但是Mongoengine抛出了以下错误:
Mongoengine.errors.ValidationError:为EmbeddedDocumentField提供的嵌入文档类无效
,但我不确定如何执行该操作。那么,如何创建引用其父文档类型的嵌入式文档?它不能引用父文档,只能引用父类型的其他文档。

我找到了解决方案。将
类中的
Document
更改为
EmbeddedDocument
,成功了