class Venue(models.Model):
    name = models.CharField(max_length=200)

def __unicode__(self):
    return self.name

def ranking(self):
    count = 0
actives = ActiveVenue.objects.filter(venue__name=self.name).values(
    'event__user__username', 'venue__name').distinct()
for active in actives:
    count += 1
return count
How to return most popular items in a table, but where each item is unique?