Mongoengine python3嵌入式文档没有属性_is_document

时间:2018-09-05 11:29:01

标签: django django-rest-framework mongoengine

我正在使用mongoengine创建一个具有EmbeddedDocument字段的文档。

但是出现以下错误:

AttributeError:“ EmbeddedDocument”对象没有属性“ _is_document”

做一些研究,我发现mongoengine的代码是用python 2编写的,并确实使它能够使用pip3正确安装。还是一样仍然无法正常工作。

class DataImportNodeInfo(EmbeddedDocument):

    provider_id = fields.IntField(required=False)
    carrier_name = fields.StringField(required=False)
    basepath = fields.StringField(required=False)
    log_tobe_imported = fields.ListField(required=False)


class DataImportConnectionInfo(EmbeddedDocument):

    host = fields.StringField(required=True)
    user_login = fields.StringField(required=False)
    user_pwd = fields.StringField(required=False)


class DataImportNode(DynamicDocument):

    # Meta variables
    meta = {
    'collection': str(KonnectDAConstants.DATA_IMPORT_NODES)
    }

    cmd = fields.StringField(required=True)
    import_source = fields.StringField(required=True)
    import_type = fields.StringField(required=True)
    active = fields.BooleanField(required=True)
    info = fields.EmbeddedDocument(DataImportNodeInfo, required=True)
    connection = fields.EmbeddedDocument(DataImportConnectionInfo, required=True)
  

AttributeError:“ EmbeddedDocument”对象没有属性“ _is_document”

1 个答案:

答案 0 :(得分:1)

您应该在select * from MY_DBSOURCE WHERE 1=1 And LP_WHERE_REP = (CASE When :LP = 'LIFESHEILD' AND :M = 'AP' AND :STATUS = 'Processed' THEN flag ='P' and Manual_FLAG = 'P' END) AND DATA_SOURCE IN ('LIFESHIELD') AND DATE_CLOSED >= '15-JUL-2019' AND DATE_CLOSED <= '16-JUL-2019' 中使用EmbeddedDocumentField而不是EmbeddedDocument

DataImportNode