如何显示来自 google 帐户的图像:django-allauth
how to display image from google account: django-allauth
我在我的应用程序中使用 django-allauth 通过 facebook 和 google 进行用户注册。我可以显示用户的 facebook 图片。但是我不知道如何为 google 做。对于 facebook,我遵循了本教程 http://www.sarahhagstrom.com/2013/09/the-missing-django-allauth-tutorial/
有人可以建议我如何在我的网站上显示 google 用户的帐户图像。
如此处所述How to populate user profile with django-allauth provider information?:
在您的服务器端代码中您可以尝试
user.socialaccount_set.filter(provider='google')[0].extra_data['picture']
在模板中你可以这样得到它
<img src="{{ user.socialaccount_set.all.0.get_avatar_url }}" />
我在我的应用程序中使用 django-allauth 通过 facebook 和 google 进行用户注册。我可以显示用户的 facebook 图片。但是我不知道如何为 google 做。对于 facebook,我遵循了本教程 http://www.sarahhagstrom.com/2013/09/the-missing-django-allauth-tutorial/
有人可以建议我如何在我的网站上显示 google 用户的帐户图像。
如此处所述How to populate user profile with django-allauth provider information?:
在您的服务器端代码中您可以尝试
user.socialaccount_set.filter(provider='google')[0].extra_data['picture']
在模板中你可以这样得到它
<img src="{{ user.socialaccount_set.all.0.get_avatar_url }}" />