Python wtforms validate_on_submit不起作用。(写入了form.hidden_​​tag())

时间:2018-12-15 15:19:24

标签: javascript python

aaa.html

<form class="form-horizontal" action="{{ url_for('zzz') }}" method="POST">
        {{ form.hidden_tag() }}
        <div class="card-body">
           <fieldset class="form-group">
             <h4 class="card-title">info</h4>       
             <div class="border-top">                       
               <div class="form-group row m-t-20">
                  {{ form.userName.label(class="col-sm-3 text-left control-label col-form-label") }}
                  <div class="col-sm-9">
                     {{ form.userName(class="form-control") }}
                  </div>
               </div>
            </div>
          </fieldset>
          <div class="form-group">
            {{ form.submit(class="btn btn-success float-right m-b-20") }}
          </div>
       </div>
</form>

zzz.py

@app.route("/zzz", methods=['GET', 'POST'])
def user_admin():
    regiform = RegisterationForm()
    if regiform.validate_on_submit():
        return redirect(url_for('abc'))
    return render_template('user_admin.html', form=regiform)

@users.route("/abc", methods=['GET', 'POST'])
def abc():
    return render_template('acac.html')

按下提交按钮validate_on_submit()无效。它应该返回到acac.html。但是它仅停留在aaa.html页上。我做错了什么?

0 个答案:

没有答案