title: Create a django-manager with dynamic filtering based on database items
body: <p>The title is a little rough so let me explain it with more details:</p>
  
  <p>I have a table called <code>Identity</code> which is a simple table like that:</p>
  
  <pre><code>class Identity(models.model):
  
      identity_name = models.CharField(max_length=20, db_index=True) # name of the ID
      service_name = models.CharField(max_length=50)
  </code></pre>
  
  <p>An example row in the database would be a Facebook identity with <code>identity_name='FacebookID'</code> and a <code>service_name='Facebook'</code>.</p>
  
  <p>Now, to link that to a user, I have the following table:</p>
  
  <pre><code>class UserIdentity(models.Model):
  
      user = models.ForeignKey('django.contrib.auth.models.User', db_index=True)
      identity_type = models.ForeignKey('Identity', db_index=True)
      value = models.CharField(maxlength=50) # the ID value
  
      objects = models.Manager()
      identities = IdentitesManager()
  </code></pre>
  
  <p>Let say <code>Bob</code> is a instance of the <code>django.contrib.auth.models.User</code>. I would like to access its Facebook identity with <code>Bob.identities.facebook</code> where <code>facebook</code> is dynamically generated in the <code>IdentitiesManager</code>. </p>
  
  <p>Now you know the context, here is the question: how do I retrieve from the database the identities, to use them in the <code>IdentitiesManager</code> ?</p>
  
  <p>Thanks for reading.</p>