5π
β
I donβt think its possible unless you delete objects one by one. From documentation:
Keep in mind that this will, whenever possible, be executed purely in SQL, and so the delete() methods of individual object instances will not necessarily be called during the process
Means MyModel.objects.all().delete()
(or bulk delete operation) will be executed in SQL level, so each object will not be called.
If you want to delete objects one by one, then you can try like this:
deleted = []
for item in MyModel.objects.all():
deleted.append(item.id)
item.delete()
print(deleted)
But it will very inefficient solution and not recommended.
π€ruddra
Source:stackexchange.com