Python 索塔mongoengine类型对象';第'节;没有属性_数据
在模型中,我定义:Python 索塔mongoengine类型对象';第'节;没有属性_数据,python,mongodb,pylons,mongoengine,Python,Mongodb,Pylons,Mongoengine,在模型中,我定义: section.py: class Section(Document): section_name = StringField(required = True) class AdminInterface(DynamicDocument): registered_model = ListField() from helloworld.model.section import Section from helloworld.model.admin_interf
section.py
:
class Section(Document):
section_name = StringField(required = True)
class AdminInterface(DynamicDocument):
registered_model = ListField()
from helloworld.model.section import Section
from helloworld.model.admin_interface import AdminInterface
model = [
Section
]
instance = AdminInterface(registered_model = model)
instance.save()
此外,在模型中:
管理界面.py
:
class Section(Document):
section_name = StringField(required = True)
class AdminInterface(DynamicDocument):
registered_model = ListField()
from helloworld.model.section import Section
from helloworld.model.admin_interface import AdminInterface
model = [
Section
]
instance = AdminInterface(registered_model = model)
instance.save()
然后,在控制器中:
\uuuu init\uuuuu.py
:
class Section(Document):
section_name = StringField(required = True)
class AdminInterface(DynamicDocument):
registered_model = ListField()
from helloworld.model.section import Section
from helloworld.model.admin_interface import AdminInterface
model = [
Section
]
instance = AdminInterface(registered_model = model)
instance.save()
我有一个错误:
AttributeError: type object 'Section' has no attribute '_data'
有没有办法解决这个问题?我真的不知道该怎么办。我想保存Section对象,以便以后可以使用
AdminInterface
显示它。您需要使用Section
实例启动模型,或者在代码中添加Section
实例。您不能只提供不可保存的类。您需要使用节
实例启动模型,或者稍后在代码中附加节
实例。您不能仅仅将类作为不可保存的类提供