Defining WTFoms form raises TypeError: Error when calling the metaclass bases

Defining WTFoms form raises TypeError: Error when calling the metaclass bases

我正在尝试使用 Flask-WTF 定义一个简单的表单。我得到 TypeError: Error when calling the metaclass bases。为什么会出现此错误?

from flask_wtf import form

class RegisterForm(form):
    pass
Traceback (most recent call last):
  File "manage.py", line 5, in <module>
    from flask_init import app
  File "/Users/sapp/Desktop/ude/flask_init/__init__.py", line 12, in <module>
    from author import views
  File "/Users/sapp/Desktop/ude/flask_init/author/views.py", line 3, in     <module>
    from form import RegisterForm
   File "/Users/sapp/Desktop/ude/flask_init/author/form.py", line 5, in <module>
    class RegisterForm(form):
TypeError: Error when calling the metaclass bases
module.__init__() takes at most 2 arguments (3 given)

您导入了模块 form 并将其作为 RegisterForm 的基础 class 传递。模块不是有效的基础 class。您正在寻找 form.Form,该模块中的 class Form

from flask_wtf.form import Form

class RegisterForm(Form):
    pass