Home > Blockchain >  How do I call this function on a button press?
How do I call this function on a button press?

Time:09-12

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

CodePudding user response:

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

  • Related