How do I call this function on a button press?

problem here is I want Student to be deleted everytime this delete button is pressed and refresh page/stay on current page, I am stuck with this problem, any solution?

<div class="content">
    {% for student in students %}
    <p class= 'my-2 text-center'>
        {{student.name}} | {{student.bio}}
        <button type="button" class="btn btn-danger">Delete</button>
    </p> 
    {% endfor %}
</div>

Since you'll be deleting entries from your model, you'll have to put the button in a form that submits the id of the student entry to a view function that then deletes that student of that id from your database.

Here's a video which explains how to do this:

Delete Items From The Database

Back to Top