Flask 編輯修改內容 功能
阿新 • • 發佈:2017-09-26
write bmi template method query ida emp render html
@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)
Flask 編輯修改內容 功能