问题描述
views.py
@receiver(post_save,sender=User)
def create_profile(sender,instance,created,**kwargs):
if created:
Profile.objects.create(user=instance)
@receiver(social_account_added)
def after_social_account_added(request,sociallogin,**kwargs):
profile = Profile.objects.filter(user=request.user).first()
sc = sociallogin.account
if DEFAULT_PP in profile.avatar.url:
if sc.provider == 'facebook':
profile.avatar = f"http://graph.facebook.com/{sociallogin.account.uid}/picture"
else:
profile.avatar = sc.extra_data[ALL_AUTH_IMAGE_KEYS[sc.provider]]
profile.save()
create_profile
在创建用户时被触发,它会创建一个新的 Profile
。
当用户添加他们的社交帐户时,after_social_account_added
会被触发,它会更新 Profile
的头像并将其设置为提供者提供的图像。
create_profile
工作正常,但 after_social_account_added
不运行。
非常感谢任何帮助。
谢谢
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)