title: Flask/Peewee Delete A Row
body: <p>I am using Peewee with Flask. I have a table of parts that I want to be able to add to, delete and update from a form. I have the add part working and am working on the delete function. This function will delete a row from the db that is equal to the part name given on the form. Here is my code:</p>
  
  <p><strong>Python/Flask</strong>
  <em>app.py</em></p>
  
  <pre><code>@app.route('/admin', methods=['GET', 'POST'])
  @login_required
  def admin():
      form = forms.PartsUpdateForm()
      if request.method == 'POST':
          choice = request.form.get('admin_choice')
      if form.validate_on_submit():
          if choice == 'add_part':
              models.Parts.create(part_name=form.part_name.data, part_desc=form.part_desc.data,
                                  part_img=form.part_img.data)
              flash("Part Created! Thanks!", "success")
              return redirect(url_for('index'))
          elif choice == 'update_part':
              flash('UPDATE : WIP')
              return redirect(url_for('index'))
          else:
              to_del = form.part_name.data
              to_del.delete()
              flash("Part deleted!", "success")
              return redirect(url_for('index'))
  </code></pre>
  
  <p>The else statement activates the deletion portion but I can't seem to get it to actually delete. I read the peewee docs and I guess I'm not understanding the instructions.</p>