Python Social Auth。与现有的Profiles模型有关

时间:2014-07-25 21:07:52

标签: django facebook django-models python-social-auth

我刚刚收录了python social auth并添加了Facebook登录信息。我有一个Profile模型,我保存了一些用户数据,如“description”和“username”。

class Profile(models.Model):
    username = models.CharField(max_length=75)
    user_des = models.CharField(max_length=250, blank=True, null=True)
    ...

如何将用户的Facebook帐户与现有模型联系起来,以及在何处保存该关系?

1 个答案:

答案 0 :(得分:1)

查看社交认证文档,我发现您可以在settings.py中使用此模型指定自定义用户模型:

SOCIAL_AUTH_USER_MODEL = 'myapp.CustomUser'

在你的情况下,它将是:

SOCIAL_AUTH_USER_MODEL = 'myapp.Profile'

我发现的文档在这里:

http://django-social-auth.readthedocs.org/en/latest/configuration.html#custom-user-model

它们还包括ORM的文档:

http://django-social-auth.readthedocs.org/en/latest/configuration.html#orms

编辑:

默认情况下,social-auth使用

django.contrib.auth.User

模型保存用户,文档可以在这里找到:

https://docs.djangoproject.com/en/dev/ref/contrib/auth/