无法从Flask-WTF导入FlaskForm

时间:2018-01-21 19:12:25

标签: python flask flask-wtforms

我有一个现有的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。

2 个答案:

答案 0 :(得分:6)

您安装了旧版本的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.

答案 1 :(得分:-1)

旧版本: 从flask_wtf导入表单