在将一个值保存到数据库中之后,我将呈现一个编辑字段html。在
表单将自动填充先前的数据。在
如何保存原始数据以便检查哪些字段已更改?在
这是我的骨架编辑视图
@app.route('/edit/<name>/<goal>/<strategy>/<task>', methods=['GET', 'POST'])
def edit_task(name,goal,strategy,task):
ptask=models.Tasks.query.filter_by(task=task).first()
form = task_form(obj=ptask)
form.populate_obj(ptask)
tform=task_form(request.values)
if request.method == 'POST' and form.validate_on_submit():
complete=tform.complete.data
#check if complete changed
db.session.commit()
return redirect(url_for('task_outline',name=name,goal=goal,strategy=strategy))
return render_template('edit_task.html', tform=tform,form=form,ptask=ptask)
这很可能会在烧瓶中工作,但我只使用过金字塔
正如limasxgoesto0所建议的,我使用了get_历史,它起作用了。这是我的测试,并解决如何测试布尔值的变化和分配新的日期为新的真
在我看来:
相关问题 更多 >
编程相关推荐