@app.route('/edit/<id>', methods=['GET', 'POST']) @login_required def edit(id): content = Article.query.filter_by(id=id).first() form = postForm(title=content.title, body=content.body) #form里面存入默认值 if form.validate_on_submit(): post = Article() post.id = int(id) post.title = form.title.data post.body = form.body.data db.session.merge(post) db.session.commit() return redirect('/post/'+id) return render_template('write.html', form=form)