# Delete confirmation not appending.

**URL:** <https://forum.djangoproject.com/t/delete-confirmation-not-appending/23293>\
**Category:** The Admin\
**Created:** [August 23, 2023, 5:10am UTC](https://forum.djangoproject.com/t/delete-confirmation-not-appending/23293 "2023-08-23T05:10:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![harshalkumar-ishi](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/harshalkumar-ishi/32/14653_2.png) [@harshalkumar-ishi](https://forum.djangoproject.com/u/harshalkumar-ishi)\
**Post date:** [August 23, 2023, 5:10am UTC](https://forum.djangoproject.com/t/delete-confirmation-not-appending/23293/1 "2023-08-23T05:10:57Z")

</div>

Delete confirmation screen is not appending while doing delete action using custom delete action for inactive records from listing screen.

Is this a bug?

---

<div class="post-metadata">

**Author:** ![addwebsolution](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/addwebsolution/32/23762_2.png) [@addwebsolution](https://forum.djangoproject.com/u/addwebsolution)\
**Post date:** [August 23, 2023, 5:28am UTC](https://forum.djangoproject.com/t/delete-confirmation-not-appending/23293/2 "2023-08-23T05:28:50Z")

</div>

Clarify your templates, what are you trying to do for which page there isn’t much you have provided like

> [@harshalkumar-ishi](#):
>
> Delete confirmation screen

What is this? like a page? or a Modal pop up?. Share your particular template where you are implementing this.

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [August 23, 2023, 12:03pm UTC](https://forum.djangoproject.com/t/delete-confirmation-not-appending/23293/3 "2023-08-23T12:03:41Z")

</div>

That confirmation screen isn’t something “automatic”. The Django admin delete action sends the confirmation page as the response to that action. Take a look at how that works in `django.contrib.admin.actions`.

If you want the confirmation page to be used, you need to do something similar to what it’s doing.

---

<div class="post-metadata">

**Author:** ![harshalkumar-ishi](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/harshalkumar-ishi/32/14653_2.png) [@harshalkumar-ishi](https://forum.djangoproject.com/u/harshalkumar-ishi)\
**Post date:** [October 9, 2023, 1:52pm UTC](https://forum.djangoproject.com/t/delete-confirmation-not-appending/23293/4 "2023-10-09T13:52:54Z")

</div>

Following are my requirements:

How do I override the admin model delete action with confirmation beforehand?

I am trying to modify the delete action that comes default with any registered model in the admin.

My goal is to override it and add in some extra functionality. This has actually been successful, but I lose the delete confirmation page beforehand. What happens instead is that the delete action fully executes and returns me back to the model’s list view immediately. I want to keep the confirmation page as an intermediary before my action goes ahead and performs its customized deletion behavior on my selected objects.

Unfortunately, I’ve gotten a bit stuck on how to do this. Does anyone know how it can be done?

So far, my code is as follows:

actions = [‘delete\_queryset’]  
def delete\_queryset(self, request, queryset):  
“”"  
delete\_queryset method is using for id selected inactive record is exists then delete it otherwise it’s not.  
“”"  
inactive\_records = queryset.filter(status=‘I’)  
count\_inactive\_records = len(inactive\_records)  
if inactive\_records.exists():  
inactive\_records.delete()  
if count\_inactive\_records == 1:  
self.message\_user(request, f"Successfully deleted Inactive capability.“, level=messages.SUCCESS)  
else:  
self.message\_user(request, f"Successfully deleted {count\_inactive\_records} Inactive capabilities.”, level=messages.SUCCESS)  
else:  
self.message\_user(request, ‘Active capability could not be deleted. Please select the inactive capability to perform delete operation.’, level=messages.WARNING)  
delete\_queryset.short\_description = “Delete selected inactive capabilities”

---

<div class="post-metadata">

**Author:** ![harshalkumar-ishi](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/harshalkumar-ishi/32/14653_2.png) [@harshalkumar-ishi](https://forum.djangoproject.com/u/harshalkumar-ishi)\
**Post date:** [October 30, 2023, 3:54am UTC](https://forum.djangoproject.com/t/delete-confirmation-not-appending/23293/5 "2023-10-30T03:54:05Z")

</div>

I have implemented the custom delete action in listing screen to delete the inactive records.  
Using overriding the delete\_queryset method in model\_admin for model.  
But before deleting the records i want to show a delete confirmation page where user can confirm the deletion of the inactive record clicking on yes or no buttons. like django admin provides for its delete action.  
I had already override the delete\_confirmation.html and delete\_selected\_confirmation.html in my django application template directory.

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [October 30, 2023, 12:07pm UTC](https://forum.djangoproject.com/t/delete-confirmation-not-appending/23293/6 "2023-10-30T12:07:17Z")

</div>

You then need to add the logic into your code to use those templates.

Your custom action needs to do two different things depending upon whether the request is a GET or a POST.

If the request is a GET, display the confirmation page and not delete the rows. This confirmation page is a form, which will submit a POST request if the confirmation button is pressed.

If the request is a POST, _then_ you delete the data.

Again, I suggest you look at the Django source code to see how the admin does this. It’s the `delete_selected` function in `django.contrib.admin.actions`.
