我的Django项目允许用户使用Google或Facebook的个人资料登录,使用pythonsocialauth的Django集成。在
他们有没有登录到谷歌的个人资料?我正试着做这样的事情:
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.contrib.auth.models import User
from django.core.mail import mail_admins
@receiver(post_save, sender=User)
def alert_new_user(sender, **kwargs):
instance = kwargs['instance']
social = instance.social_auth.last() # Assuming .last() gives me the one just added
if social is not None:
mail_admins('New user resistration',
'A new user registered with name {}'.format(instance.get_full_name()),
'<html><head/><body>A new user, <a href="{}">{}</a>, registered.</body></html>'.format(
???What goes here???, instance.get_full_name()
)
)
在他们登录之前,你可以获得他们Facebook个人资料的链接。在
在
pipeline
中,有一个名为social_details
的函数,它从指定的社交网络获取有关用户的信息。在如果我们看看这个方法,它非常简单:
如果你
^{pr2}$print
这个response
:您将看到有一个参数
link
,前提是通过Facbook登录。现在您可以获得link
并根据需要保存/使用它。在相关问题 更多 >
编程相关推荐