How to populate user profile with django-allauth provider information?

前端 未结 4 482
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-13 02:36

I\'m using django-allauth for my authentication system. I need that when the user sign in, the profile module get populated with the provider info (in my case facebook).

4条回答
  •  感情败类
    2020-12-13 03:20

    I am doing in this way and taking picture (field) url and google provider(field) as an example.

    socialaccount_obj = SocialAccount.objects.filter(provider='google', user_id=self.user.id)
       picture = "not available"
       if len(socialaccount_obj):
                picture = socialaccount_obj[0].extra_data['picture']
    

    make sure to import : from allauth.socialaccount.models import SocialAccount

提交回复
热议问题