【发布时间】:2019-04-30 15:00:19
【问题描述】:
我是 Python 新手,我想用 Wtforms 创建一个简单的页面,但是这段代码给了我 UnboundField 错误。 有人可以帮我解决问题吗?
谢谢
from flask_wtf import Form
from wtforms import StringField
from wtforms import TextField
from wtforms import SelectField
from wtforms import RadioField
from wtforms import DecimalField
from wtforms import SubmitField
from datetime import datetime
from flask import render_template
from FlaskWebProject1 import app
class StudyManagementForm(Form):
"""This seemingly static class will be transformed
by the WTForms metaclass constructor"""
study = TextField("Study")
active = RadioField("Etude active")
submit = SubmitField("Ok")
def __init__(self):
print ('a')
@app.route('/')
@app.route('/study_management', methods=['GET', 'POST'])
def study_management():
submitForm = StudyManagementForm()
return render_template(
'study_management.html',
form = submitForm
)
我得到了 UnboundField 错误:
<UnboundField(TextField, ('Study',), {})>
<UnboundField(RadioField, ('Etude active',), {})>
【问题讨论】:
标签: python flask flask-wtforms wtforms