5

I am using django-allauth for user registration in my application via facebook and google. I can display the facebook image of the user. But I have no idea how to do it for google. for facebook, i have followed this tutorial http://www.sarahhagstrom.com/2013/09/the-missing-django-allauth-tutorial/

Can somebody suggest me how to display the google account image of user in my website.

Rohit
  • 475
  • 1
  • 7
  • 16

1 Answers1

8

As mentioned here How to populate user profile with django-allauth provider information? :

In your server-side code your can try

user.socialaccount_set.filter(provider='google')[0].extra_data['picture']

and in template you can get it like that

<img src="{{ user.socialaccount_set.all.0.get_avatar_url }}" />
Community
  • 1
  • 1
Amr Abdelaziz
  • 577
  • 4
  • 12
  • 3
    What if the user hasn't set a picture, will this return `None` or a default picture URL? – Flimm Sep 07 '19 at 12:34