How to achieve bulk soft delete in django?

78 views
Skip to first unread message

Sencer Hamarat

unread,
Jun 16, 2022, 10:14:47 AM6/16/22
to django...@googlegroups.com
Hi,

The models delete methods overridden by default and has a soft delete mechanizm.

I need to add bulk soft delete to the application. I can achieve this with iterating over objects to call the soft delete method. But the actual need is, soft delete objects filtered by id in bulk way.

Can I do it without iterating the object list?

Regards,
Sencer HAMARAT

Ryan Nowakowski

unread,
Jun 16, 2022, 10:44:21 PM6/16/22
to django...@googlegroups.com
Add a soft delete method to a custom QuerySet, then use that as a custom Manager for your model.

https://docs.djangoproject.com/en/4.0/topics/db/managers/#creating-a-manager-with-queryset-methods
Reply all
Reply to author
Forward
0 new messages