WTForms-JSON not working with FormFields

跟風遠走 提交于 2019-12-05 14:18:36
haeger

I was using the from_json()-function wrong, as it is a class-function that returns an instantiated form. See updated code for route below.

@app.route('/', methods=['POST'])
def why_no_work():
    form = User.from_json(request.json)  # <-- This line right here

    if form.validate():
        return jsonify(success='YEAH')
    else:
        return jsonify(errors=form.errors)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!