search

Home  >  Q&A  >  body text

python - Learning flask web development Chapter 4 validate_on_submit encountered an error and no attributes

app.py代码如下:

from flask import Flask, render_template
from flask_bootstrap import Bootstrap
from flask_wtf import Form
from wtforms import StringField, SubmitField,validators
from 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'
我在网上试过其他的方法没用,我也不清楚哪里有问题。
希望大家能帮帮我!!!
曾经蜡笔没有小新曾经蜡笔没有小新2755 days ago698

reply all(1)I'll reply

  • 过去多啦不再A梦

    过去多啦不再A梦2017-05-18 11:00:32

    It’s validate, okay! Why don't you see the error message?

    reply
    0
  • Cancelreply