for duplicates in Tag.objects.values("name").annotate( records=Count("name") ).filter(records__gt=1): for tag in Tag.objects.filter(name=duplicates["name"])[1:]: tag.delete()