我正在尝试使用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)
答案 0 :(得分:1)
您导入了模块form
并将其作为RegisterForm
的基类传递。模块不是有效的基类。您正在寻找form.Form
,该模块中的课程Form
。
from flask_wtf.form import Form
class RegisterForm(Form):
pass