django - Allauth social_account_added 信号未发送
问题描述
视图.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
并将其设置为 Provider 提供的图像。
create_profile
工作正常,但不after_social_account_added
运行。
非常感谢任何帮助。
谢谢
解决方案
推荐阅读
- javascript - 阿博杜随机数
- sql-server - 为什么聚集索引查找工作缓慢?
- postgresql - Postgresql:如何在最后一个分隔符之后修剪字符串,仅当有多个分隔符时
- java - 对函数的调用不对应于任何重载
- bash - (CRON) 信息(未安装 MTA,丢弃输出)已发送消息电报
- c++ - constexpr 与匿名命名空间
- javascript - 如何使输入字段只接受数字
- c# - 是否可以从不活跃的广告中检索 Facebook 潜在客户?
- spring - 如何在 spring-boot 应用程序启动期间创建许多 kafka 主题?
- c++ - Windows 10 下 Winhttp SSL 的问题