简体   繁体   中英

wtforms returns only None

I have the following HTML, CSS and JS code . However, when I use the search from the top right side and press enter. Flask only get "None" and what was typed in search.

This is the route for the search:

@app.route("/quick_search/", methods=("GET", "POST"))
@app.route("/quick_search/<property_id>")
def quick_search(property_id=None):
    form = QuickSearch()
    print "???", form.propert_name.data

and this form class:

from flask.ext.wtf import Form
from wtforms import SelectField, StringField, IntegerField, SelectMultipleField

class QuickSearch(Form):
    propert_name = StringField()

Why I only get None from form.propert_name.data ?

You name your field propert_name in the WTForms instance and in the Flask view. But in the HTML it is called quick_search .

You also use the attribute type twice in the input tag. You say type="text" and then you redefine type to submit later on. This shouldn't cause the problem, but worth it to take care…

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM