タイトルは少しラフなので、詳しく説明します。
Identity
私はそのような単純なテーブルであると呼ばれるテーブルを持っています:
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)
identity_name='FacebookID'
データベースの行の例は、とのFacebookIDservice_name='Facebook'
です。
これをユーザーにリンクするために、次の表があります。
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()
Bob
のインスタンスだとしましょうdjango.contrib.auth.models.User
。で動的に生成されるBob.identities.facebook
場所を使用して、FacebookIDにアクセスしたいと思います。facebook
IdentitiesManager
これでコンテキストがわかりました。ここに質問があります。データベースからIDを取得して、それらをIdentitiesManager
?で使用するにはどうすればよいですか。
読んでくれてありがとう。