title: Django annotate on BooleanField
body: <p>I have the following models:</p>
  
  <pre><code>class Foo(models.Model):
      pass
  
  class Bar(models.Model):
      foo = models.ForeignKey(Foo)
      is_successful = models.BooleanField()
  </code></pre>
  
  <p>I would like to get all <code>foo</code> objects with an annotation if all of the <code>bar</code> objects associated with <code>foo</code> object have <code>is_successful</code> as <code>True</code></p>
  
  <p>So far my queryset is:</p>
  
  <pre><code>foos = Foo.objects.all().annotate(all_successful=Min('bar__is_successful'))
  </code></pre>
  
  <p>The idea for the <code>all_successful</code> annotation is that if the minimum value of all <code>is_successful</code> rows is 1, then all of them must be <code>True</code> (assuming <code>0</code> is <code>False</code> and <code>1</code> is <code>True</code>). So knowing that I can use the queryset like so:</p>
  
  <pre><code>foo = foos[0]
  
  if foo.all_successful == 1:
      print 'All bars are successful'
  else:
      print 'Not all bars are successful'
  </code></pre>
  
  <p>This works great in sqlite however it fails in PostgreSQL because PostgreSQL can't execute <code>MIN</code> aggregate on a boolean column. I guess this works in sqlite because sqlite treats bools as integers hence it can execute the aggregate.</p>
  
  <p>My question is how can I make this queryset work in PostgreSQL without converting my <code>is_successful</code> field to an <code>IntegerField</code>?</p>
  
  <p>Thanx</p>