title: Django : Count only non-empty CharField with annotate() & values()
body: <p><a href="https://docs.djangoproject.com/en/dev/ref/models/fields/#null" rel="nofollow">Django recommends</a> not using <code>null</code> on <code>CharField</code>, however annotate includes empty strings in the count. Is there a way to avoid that without excluding rows with empty string from the query? </p>
  
  <p>My question isn't simly how to achieve my query, but fundamentally, <strong>should Annotate/Aggregate count include empty fields</strong> or not. Django consider empty as a replacement for NULL for string based fields. </p>
  
  <p>My model : </p>
  
  <pre><code>class Book(models.Model):
      name = models.CharField(...)
  
  class Review(models.Model):
      book = models.ForeignKey()
      category = models.ForeignKey()
      review = models.CharField(max_length=200, default='', blank=True)
  </code></pre>
  
  <p>To count non-empty reviews &amp; group by category, I use</p>
  
  <pre><code>Review.objects.values('category').annotate(count=Count('review'))
  </code></pre>
  
  <p>This doesn't work because annotate counts empty values also (if the entry was NULL, it wouldn't have done so). I could filter out empty strings before the annotate call but my Query is more complex and I need all empty &amp; non-empty objects. </p>
  
  <p>Is there a smarter way to use <strong>annotate and skip empty values</strong> from count or should I change the model from </p>
  
  <pre><code>review = models.CharField(max_length=200, default='', blank=True)
  </code></pre>
  
  <p>to </p>
  
  <pre><code>review = models.CharField(max_length=200, default=None, blank=True, null=True)
  </code></pre>