Entry only delete first object

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.

def category_delete(request, id):
if request.method == ‘POST’:
return HttpResponseRedirect(’/api/custom_admin/category’)


                                                            <!-- Modal Header -->
                                                            <div class="modal-header">
                                                                <h4 class="modal-title">Click Yes for Delete Product</h4>
                                                                <button type="button" class="close" data-dismiss="modal">&times;</button>

                                                            <!-- 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>

This looks like django so my reply is based on django.

One thing missing is what your urls.py file looks like.

You can review html forms here, you’re missing a name attribute:


You don’t need to (and probably shouldn’t on a post request) pass the id like this. Give your form inputs name attributes like:

Then in your view access id with:

Adjust the path in you urls.py accordingly.


path('category/', views.show_category, name='showcategory'),
path('addcategory/', views.add_category, name='addcategory'),
path('updatecategory/<str:id>', views.category_edit, name='updatecategory'),
path('deletecategory/<str:id>', views.category_delete, name='deletecategory'),

That is what I expected would be there, which is fine for a GET request. But for a POST request look at my previous comment.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.