title: Django query to list the count of field values distinctly
body: <p>I have a model which has a field named 'state'. It has values like 'completed', 'in_progress', 'failed', 'created'. I need to know if I can write a django query which will through me a list like</p>
  
  <pre><code>{'completed': 2, 'in_progress': 5, 'failed': 0, 'created': 2}
  </code></pre>
  
  <p>for the table values</p>
  
  <pre><code>id | order_id | state
  ---------------------------
  1  | 23       | completed
  2  | 23       | completed
  3  | 23       | in_progress
  4  | 23       | created
  5  | 23       | created
  6  | 23       | in_progress
  7  | 23       | in_progress
  8  | 23       | in_progress
  9  | 23       | in_progress
  </code></pre>
  
  <p>I tried running the below query</p>
  
  <pre><code>order_items = OrderItems.objects.filter(order=order)
  order_states = order_items.filter(
      state__in=['in_progress', 'completed', 'failed', 'created']
  ).values('state').annotate(Count('state'))
  </code></pre>
  
  <p>But it gave me a list which came up like this</p>
  
  <pre><code>[{'state': u'completed', 'state__count': 8}, 
  {'state': u'failed', 'state__count': 1}, 
  {'state': u'in_progress', 'state__count': 1}]
  </code></pre>