我有一个现有的 Flask 应用程序,正在尝试向其中添加 Flask-Blogging 扩展。当 ImportError: cannot import name FlaskForm 尝试 flask_blogging 时,添加扩展会引发 from flask_wtf import FlaskForm

Traceback (most recent call last):
  File "run.py", line 11, in <module>
    blog_engine = BloggingEngine(app, sql_storage)
  File "/usr/local/lib/python2.7/dist-packages/flask_blogging/engine.py", line 66, in __init__
    self.init_app(app, storage)
  File "/usr/local/lib/python2.7/dist-packages/flask_blogging/engine.py", line 96, in init_app
    from .views import create_blueprint
  File "/usr/local/lib/python2.7/dist-packages/flask_blogging/views.py", line 11, in <module>
    from flask_blogging.forms import BlogEditor
  File "/usr/local/lib/python2.7/dist-packages/flask_blogging/forms.py", line 1, in <module>
    from flask_wtf import FlaskForm
ImportError: cannot import name FlaskForm

我正在使用 Flask 0.11.1 和 Flask-WTF 0.12。

最佳答案

您安装了旧版本的 Flask-WTF,但 Flask-Blogging 需要更新版本。升级 Flask-WTF。

pip install -U Flask-WTF

Flask-WTF renamed Form to Flask-Form in version 0.13, released September 29, 2016.

关于python - 无法从 Flask-WTF 导入 FlaskForm,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/48370668/

10-11 07:42