[Answered ]-How to delete a slice

2👍

Maybe you want something like this:

batch_size = 10000
max_id = Catalog.objects.order_by('-id')[0].id
for start in range(0, max_id, batch_size):
    end = min(start + batch_size, max_id)
    Catalog.objects.filter(pk__gte=start, pk__lte=end).delete()

Leave a comment