今日、私は奇妙なことを発見しました。説明が必要です。
これは私の現在のパイプラインですdjango-social-auth
SOCIAL_AUTH_PIPELINE = (
'social_auth.backends.pipeline.social.social_auth_user',
'social_auth.backends.pipeline.associate.associate_by_email',
'social_auth.backends.pipeline.user.get_username',
'social_auth.backends.pipeline.user.create_user',
'social_auth.backends.pipeline.social.associate_user',
'apps.main.pipeline.load_user_data',
'social_auth.backends.pipeline.social.load_extra_data',
'social_auth.backends.pipeline.user.update_user_details'
)
ご覧のとおり、部分的なパイプラインである load_user_data メソッドがあり、そこに問題があります。
def load_user_data(request, user, *args, **kwargs):
x = User.objects.get(id=user.id)
x.fid = 123
x.save() # <-- Nothing changes in db . I even used force_update attribute.
user.fid = 123
user.save() # <-- it works.
だから、なぜx.save()
うまくいかなかったのか理解できません。私はこの問題に何時間も苦労しました。