我无法通过post请求使用html表单中的用户输入在数据库中创建新记录。我收到错误消息“错误请求浏览器(或代理)发送了此服务器无法理解的请求。”
@app.route("/create_profile", methods=['GET','POST'])
def create_profile():
if request.method == 'POST':
n = request.form['name']
z = request.form['zipcode']
i1 = request.form['dancing']
i2 = request.form['football']
i3 = request.form['art']
u = User(name=n, zipcode=z, inter1=i1, inter2=i2, inter3=i3 )
db.session.add(u)
db.session.commit
return render_template("create_profile.html")
答案 0 :(得分:0)
db.session.commit()