title: django most efficient way to count same field values in a query
body: <p>Lets say if I have a model that has lots of fields, but I only care about a charfield. Lets say that charfield can be anything so I don't know the possible values, but I know that the values frequently overlap. So I could have 20 objects with "abc" and 10 objects with "xyz" or I could have 50 objects with "def" and 80 with "stu" and i have 40000 with no overlap which I really don't care about. </p>
  
  <p>How do I count the objects efficiently? What I would like returned is something like:</p>
  
  <p>{'abc': 20, 'xyz':10, 'other': 10,000}</p>
  
  <p>or something like that, w/o making a ton of SQL calls. </p>
  
  <h2>EDIT:</h2>
  
  <p>I dont know if anyone will see this since I am editing it kind of late, but... </p>
  
  <p>I have this model:</p>
  
  <pre>
  class Action(models.Model):
      author = models.CharField(max_length=255)
      purl = models.CharField(max_length=255, null=True)
  </pre>
  
  <p>and from the answers, I have done this:</p>
  
  <pre>
  groups = Action.objects.filter(author='James').values('purl').annotate(count=Count('purl'))
  </pre>
  
  <p>but...</p>
  
  <p>this is what groups is:</p>
  
  <pre>
  {"purl": "waka"},{"purl": "waka"},{"purl": "waka"},{"purl": "waka"},{"purl": "mora"},{"purl": "mora"},{"purl": "mora"},{"purl": "mora"},{"purl": "mora"},{"purl": "lora"}
  </pre>
  
  <p>(I just filled purl with dummy values)</p>
  
  <p>what I want is</p>
  
  <pre>
  {'waka': 4, 'mora': 5, 'lora': 1}
  </pre>
  
  <p>Hopefully someone will see this edit...</p>
  
  <h2>EDIT 2:</h2>
  
  <p>Apparently <strong>my database</strong> (BigTable) <strong>does not support the aggregate functions</strong> of Django and this is why I have been having all the problems.</p>