title: Django admin annotation is multiplied if search_field (by related FK),
body: <p>i have problem with multiplation of annotation...</p>
  <p>if i use search_field by email <code>useremail__email</code> (related fk of user model) ... then my annotation is multipled
  the problem is if the table with profileemails is joined (without search it works just good)</p>
  <p>in example:
  i have user named admin and emails.. admin1, admin2, admin3<br />
  then search is done by <code>admin</code>
  the result is sum * 3 (because 3 emails)</p>
  <p>my model:</p>
  <pre><code>class Payment(models.Model):
      user = models.ForeignKey(User, on_delete=models.CASCADE)
      amount = models.IntegerField()
  
  
  class SubPayment(models.Model):
      payment = models.ForeignKey(Payment, on_delete=models.CASCADE)
      amount = models.IntegerField()
  
  
  class UserEmail(models.Model):
      user = models.ForeignKey(User, on_delete=models.CASCADE)
      email = models.CharField(max_length=128)
  </code></pre>
  <p>in admin i have User model where i want to display sum and count of subpayments:</p>
  <pre><code>class UserAdmin(admin.ModelAdmin):
      list_display = (&quot;username&quot;, &quot;payment_count&quot;, &quot;payment_sum&quot;)
      search_fields = (
          'useremail__email',
          'username'
      )
  
  def payment_count(self, obj):
      return obj.payment_count
  
  def payment_sum(self, obj):
      return obj.payment_sum
  
  def get_queryset(self, request, *args, **kwargs):
  
      queryset = super().get_queryset(request, *args, **kwargs).annotate(
              payment_amount=Sum('payment__amount'),
              payment_count=Count('payment__subpayment'),
              payment_sum=Sum('payment__subpayment__amount'),
          )
      return queryset
  </code></pre>
  <p>I tried use distinct=True , but it remove duplicite subpayments with same amount...</p>
  <p>tried on django 2.2 and 3.17</p>
  <p>works good:
  <a href="https://i.stack.imgur.com/3b0Vm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3b0Vm.png" alt="enter image description here" /></a></p>
  <p>works wrong:
  <a href="https://i.stack.imgur.com/DLDgG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DLDgG.png" alt="enter image description here" /></a>
  Any help?</p>
  <p>Thanks!</p>