[英]Defining WTFoms form raises TypeError: Error when calling the metaclass bases
我正在嘗試使用Flask-WTF定義一個簡單的表單。 我TypeError: Error when calling the metaclass bases
收到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
的基類傳遞。 模塊不是有效的基類。 您正在尋找form.Form
,該模塊中的類Form
。
from flask_wtf.form import Form
class RegisterForm(Form):
pass
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.