wtforms returns only None

▼魔方 西西 提交于 2021-02-11 13:56:09

问题


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?


回答1:


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 inputtag. 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…



来源:https://stackoverflow.com/questions/27576895/wtforms-returns-only-none

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!