我正在使用烧瓶和 mongoDB 和 Pymodm 作为 ODM 编写一个待办事项应用程序。我有两个名为 User 和 UserGroups 的模型。这两个相互引用,如下所示:
用户.py
from api.models.userGroup import group
class User(MongoModel):
_id = fields.IntegerField(primary_key=True)
email = fields.CharField()
password = fields.CharField()
createdAt = fields.DateTimeField(default=datetime.datetime.now())
groups = [fields.ReferenceField('group')]
personalTodoLists = fields.EmbeddedDocumentListField('list')
用户组.py
from api.models.user import user
class UserGroup(MongoModel, EmbeddedMongoModel):
_id = fields.IntegerField(primary_key=True)
name = fields.CharField()
createdAt = fields.DateTimeField(default=datetime.datetime.now())
ownerId = fields.ReferenceField('user')
contributors = [fields.ReferenceField('user')]
todoLits = fields.EmbeddedDocumentListField('list')
我收到错误消息:“ImportError:无法导入名称‘用户’”
在这种情况下,我怎样才能正确引用?