Rumah > Soal Jawab > teks badan
app.py代码如下:
dari flask import Flask, render_template
from flask_bootstrap import Bootstrap
from flask_wtf import Borang
dari wtforms import StringField, SubmitField,validators
dari wtforms.validators import DataRequired
form表单代码
@app.route('/')
def hello_world():
name = None
form = NameForm()
if form.validata_on_submit():
name = form.name.data
form.name.data = ''
return render_template("index.html",form=form,name=name)
class类
class NameForm(Form):
name = StringField('What is your name?', validators=[DataRequired()])
submit = SubmitField('Submit')
bug
builtins.AttributeError
AttributeError: 'NameForm' object has no attribute 'validata_on_submit'
我在网上试过其他的方法没用,我也不清楚哪里有问题。
希望大家能帮帮我!!!