title: Django: remove duplicates (group by) from queryset by related model field
body: <p>I have a Queryset with a couple of records, and I wan't to remove duplicates using the related model field. For example:</p>
  
  <pre><code>class User(models.Model):
      group = models.ForeignKey('Group')
      ...
  
  class Address(models.Model):
      ...
      models.ForeignKey('User')
  
  addresses = Address.objects.filter(user__group__id=1).order_by('-id')
  </code></pre>
  
  <p>This returns a QuerySet of Address records, and I want to group by the User ID.</p>
  
  <ul>
  <li>I can't use <code>.annotate</code> because I need all fields from Address, and the relationship between Address and User</li>
  <li>I can't use <code>.distinct()</code> because it doesn't work, since all addresses are distinct, and I want distinct user addresses.</li>
  </ul>
  
  <p>I could:</p>
  
  <pre><code>addresses = Address.objects.filter(user__group__id=1).order_by('-id')
  unique_users_ids = []
  unique_addresses = []
  
  for address in addresses:
      if address.user.id not in unique_users_ids:
          unique_addresses.append(address)
          unique_users_ids.append(address.user.id)
  
  print unique_addresses # TA-DA!
  </code></pre>
  
  <p>But it seems too much for a simple thing like a group by (damn you Django).</p>
  
  <p>Is there a easy way to achieve this?</p>