title: Django friends as many-to-many field - better storing User or UserProfile (self) in field?
body: <p>I found two ways of implementing a <strong>symmetrical friendship</strong> system (you are my friend, so I am also your friend) in Django:</p>
  
  <p>As suggested inside the docs:</p>
  
  <pre><code>class UserProfile(models.Model):
      friends = models.ManyToManyField(User, related_name='friends')
  </code></pre>
  
  <p>Now, I'd like to get all "friendly" user AND userprofile models with one select_related-query like so (that should be a reverse joined lookup):</p>
  
  <pre><code>profiles = UserProfile.objects.filter(user__in=request.user.get_profile().friends.all()).select_related()
  </code></pre>
  
  <p>I query the userprofile, because that way, I can use select_related() and all related objects are cached.</p>
  
  <p>On the other hand, I can define my model referencing the friends field to "self", like so:</p>
  
  <pre><code>class UserProfile(models.Model):
      friends = models.ManyToManyField('self')
  </code></pre>
  
  <p>Now, my select_related friend lookup looks like that:</p>
  
  <pre><code>profiles = this_user.get_profile().friends.all().select_related()
  </code></pre>
  
  <p>I always need both, the user object and it's related profile: The second approach is much simpler concerning the reversed lookup via select_related(), but does practically the same. However, by using "self" as field reference, Django handles for me the symmetrical friendship. Thus, I don't have to create two entries per friendship in the database manually. Django does that for me. The symmetrical option, however, does only work on "self" referencing fields.</p>
  
  <p>Which is the better solution? I can't find anything about it. Any ideas appreciated - thanks!</p>