how to display image from google account: django-allauth

3.5k views Asked by At

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.

1

There are 1 answers

1
Amr Abdelaziz On BEST ANSWER

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 }}" />