I am creating my a document having a field as EmbeddedDocument using mongoengine.
But I am getting the following error :
AttributeError: 'EmbeddedDocument' object has no attribute '_is_document'
Doing some reasearch I found that the code of mongoengine is written in python 2 and do make it work properly install it using pip3. Did the same still not working.
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' object has no attribute '_is_document'
You should use EmbeddedDocumentField
instead of EmbeddedDocument
in DataImportNode
:
info = fields.EmbeddedDocumentField(DataImportNodeInfo, required=True)
connection = fields.EmbeddedDocumentField(DataImportConnectionInfo, required=True)
Since the EmbeddedDocumentField
is used to reference the EmbeddedDocument
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With