2👍
✅
I can’t understand when this would be useful, but here’s one way
import random
ids = random.sample(Book.objects.values_list('pk', flat=True), 100)
Book.objects.filter(pk__in=ids).delete()
Source:stackexchange.com