这是我开的车,Here
并得到这个错误
**mongoengine.errors.NotRegistered:** `Comment` has not been registered in the document registry. Importing the document class automatically registers it, has it been imported?任何想法。非常感谢。
发布于 2015-04-16 23:28:40
只需将评论模型放在帖子模型之上,因为帖子模型中引用了评论模型
发布于 2016-01-05 22:56:24
首先,在models包中的某个位置注册所有模型,比如__init__.py文件。
然后,您可以使用get_document('Comment')函数(从mongoengine.base.common导入),而不是在彼此的脚本中导入模型,以避免循环导入和mongoengine.errors.NotRegistered等异常
https://stackoverflow.com/questions/29520528
复制相似问题