def delete(self, *args, **kwargs):
<EOL>from fields import RatingField<EOL>qs = self.distinct().values_list('<STR_LIT>', '<STR_LIT>').order_by('<STR_LIT>')<EOL>to_update = []<EOL>for content_type, objects in itertools.groupby(qs, key=lambda x: x[<NUM_LIT:0>]):<EOL><INDENT>model_class = ContentType.objects.get(pk=content_type).model_class()<EOL>if model_class:<EOL><INDENT>to_update.extend(list(model_class.objects.filter(pk__in=list(objects)[<NUM_LIT:0>])))<EOL><DEDENT><DEDENT>retval = super(VoteQuerySet, self).delete(*args, **kwargs)<EOL>for obj in to_update:<EOL><INDENT>for field in getattr(obj, '<STR_LIT>', []):<EOL><INDENT>getattr(obj, field.name)._update(commit=False)<EOL><DEDENT>obj.save()<EOL><DEDENT>return retval<EOL>
Handles updating the related `votes` and `score` fields attached to the model.