Hello Every time i delete my object entry with pop up button. My first entry is deleted and when i deleted it without using pop up it will delete the entry which i select.
views.py:-
def category_delete(request, id):
if request.method == ‘POST’:
pi=Category.objects.get(pk=id)
pi.delete()
return HttpResponseRedirect(’/api/custom_admin/category’)
category.html
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">Click Yes for Delete Product</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<!-- Modal body -->
<div class="modal-body">
<div class="mod-main">
<form action="/api/custom_admin/deletecategory/{{cat.uuid}}" method="post">{% csrf_token %}
<div class="appendid"></div><input type="submit" class="btn btn-danger" value="Yes"></form>
<button class="btn btn-warning" data-dismiss="modal"> No </button>
</div>
</div>