‘’’
from flask import Flask,render_template
from flask_wtf import Form, FlaskForm
from wtforms import SubmitField,BooleanField,FieldList,FormField
app = Flask(name)
app.config[‘SECRET_KEY’]=‘hard to guess string’ #密钥
class Item(FlaskForm):
edit1 = BooleanField(‘edit’, default=False)
submit = SubmitField(“提交”)
class Mform(FlaskForm):
item_list=FieldList(FormField(Item), min_entries=0)
submit = SubmitField(“确定”)
@app.route(’/’)
def hello_world():
form=Mform()
item=Item()
form.item_list.append_entry(item)
return render_template('home.html',**locals())
if name == ‘main’:
app.run()
‘’’
‘’’
Title {% for i in form.item_list %} {{ i.edit1 }}这是item_list{{ i.submit }}{% endfor %} {{ item.edit1 }}这是item{{ item.submit }}
{{form.submit}} ''' ![333|299x211](upload://b4eD0eRLjOL071t5HhOIXdC59Wn.jpeg)