python wtf AttributeError: 'ObjectIdField' object has no attribute 'help_text'

柔情痞子 提交于 2019-12-04 19:17:07

Edit:

As per comment #2 by user Jérôme, the current version (0.7.5 at the moment of this edit) of flask-mongoengine (and mongoengine 0.10.5) works straight out of the box. Tested and verified.

I'm doing the same tutorial and encountered that error too.

I added help_text="Your helptext here." to the fields (these were StringFields) in models.py and that solved the issue, but your error points to ObjectIdField, and that makes it a lot more puzzling.

So this isn't horribly helpful, but maybe it'll inspire you in the right direction.

Edit:

I wrestled with this for a while more, and turns out there's been a change in mongoengine that broke flask_mongoengine. This commit in flask_mongoengine in turn fixes that.

As for actual solutions, using a previous version of mongoengine (0.10.1) worked for me. So:

$ pip uninstall mongoengine
$ pip install mongoengine==0.10.1

Current available version of Flask-MongoEngine 0.7.5 fixes this issue.

It resolves MongoEngine deprecated help_text and safe attribute issues.

Upgrade your existing version of Flask-MongoEngine using pip install --upgrade flask-mongoengine.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!