0

I am displaying a list (of items) on a Web App developed with Python. As part of the list I am showing a 'delete' action for each item that routes to python delete like this:

<a href="/item/delete/{{ item['id'] }}">Delete</a>

My Python route looks like this:

@app.route('/item/delete/<id>', methods=['GET'])
def delete_item(id):
  item = Item.query.get(id)
  db.session.delete(item)
  db.session.commit()

  return redirect(url_for('items'))

This deletes the item from the database, but I want to ask for confirmation before actually doing the delete, but cannot seem to find a 'Confirmation' type dialog to insert into my above Python code. Can anyone please advise?

I hope this is clear, but let me know if more information is needed.

Regards Louw Pieters

  • 1
    use a confirmation modal before sending request. [example here](https://www.tutorialrepublic.com/snippets/preview.php?topic=bootstrap&file=delete-confirmation-modal) – Kurohige Jun 13 '21 at 08:53

0 Answers0