title: flask edit a database field and retain previous value using wtf form
body: <p>After saving a value into my database, I am rendering an edit_field html.  </p>
  
  <p>the form auto-populates with prior data.  </p>
  
  <p>how do i save the original data so i can check which fields changed?</p>
  
  <p>here is my skeleton edit view</p>
  
  <pre><code>@app.route('/edit/&lt;name&gt;/&lt;goal&gt;/&lt;strategy&gt;/&lt;task&gt;', 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)
  </code></pre>