title: Django: NotImplementedError: annotate() + distinct(fields) is not implemented
body: <p>There are 2 simple models:</p>
  
  <pre><code>class Question(TimeStampedModel):
      text = models.CharField(max_length=40)
  
  class Answer(TimeStampedModel):
      question = models.ForeignKey(Question, related_name='answers')
      is_agreed = models.BooleanField()
      author = models.ForeingKey(User, related_name='answers')
  </code></pre>
  
  <p>And there is my problem:</p>
  
  <pre><code>In [18]: Question.objects.count()
  Out[18]: 3
  </code></pre>
  
  <p>I need to annotate queryset with 'is_user_agreed' and 'answers_amount' fields:</p>
  
  <pre><code>In [18]: user = User.objects.first() 
  In [19]: qs = Question.objects.annotate(
      ...:             is_user_agreed=Case(
      ...:                 When(answers__in=user.answers.filter(is_agreed=True), then=Value(True)),
      ...:                 When(answers__in=user.answers.filter(is_agreed=False), then=Value(False)),
      ...:                 default=Value(None),
      ...:                 output_field=NullBooleanField(),
      ...:             ),
      ...:         ).annotate(answers_amount=Count('answers'))
      ...: qs.count()
  Out[19]: 4 
  </code></pre>
  
  <p><strong>^ here count is 4, but I have only 3 questions in db</strong> :(
  So, I've tried with <code>distinct()</code></p>
  
  <pre><code>In [20]: qs.distinct().count()
  Out[20]: 4  # but distinct doesn't work
  
  In [21]: qs.distinct('id').count()
  </code></pre>
  
  <p>And after last line of code I've got this exception:</p>
  
  <pre><code>NotImplementedError: annotate() + distinct(fields) is not implemented.
  </code></pre>
  
  <p>I've also tried to use this trick <code>annotate(Count('id')).filter(id__count__gt=1)</code></p>
  
  <p>But in this case I'm losing all duplicate rows, and qs.count() is 2.</p>
  
  <p><strong>UPDATE:</strong> The problem is duplicated rows in queryset.</p>
  
  <p><strong>SOLUTION:</strong> (Extended variant of Vladimir's second approach) </p>
  
  <pre><code>user = User.objects.first()
  user_agreed_questions = user.answers.filter(
      is_agreed=True).values_list('question_id', flat=True)
  
  user_not_agreed_questions = user.answers.filter(
      is_agreed=False).values_list('question_id', flat=True)
  
  Question.objects.annotate(
      answer_amount=Count('answers'),
      is_user_agreed=Case(
           When(id__in=user_agreed_questions, then=True),
           When(id__in=user_not_agreed_questions, then=False),
           default=None,
           output_field=NullBooleanField(),
      ),
  )
  </code></pre>