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: