1

我刚刚包含了 python social auth 并添加了 Facebook 登录。我有一个配置文件模型,我在其中保存一些用户数据,如“描述”和“用户名”。

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

如何将用户的 Facebook 帐户与现有模型相关联,我在哪里保存该关系?

4

1 回答 1

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/

于 2014-07-25T21:26:58.017 回答