DSA已經支持多帳戶關聯,關鍵是它是用戶必須先登錄,否則DSA不知道它應該與已經存在的關聯帳戶。
關於您的個人資料,將功能添加到DSA推薦的方法是通過擴展pipeline,您可以創建這樣一個條目:
def create_profile(user, is_new=False, *args, **kwargs):
if is_new:
# create a profile instance for the given user
create_user_profile(user)
然後在這樣的設置進行註冊:
SOCIAL_AUTH_PIPELINE = (
'social_auth.backends.pipeline.social.social_auth_user',
'social_auth.backends.pipeline.user.get_username',
'social_auth.backends.pipeline.user.create_user',
'social_auth.backends.pipeline.social.associate_user',
'social_auth.backends.pipeline.social.load_extra_data',
'social_auth.backends.pipeline.user.update_user_details',
'myapp.pipeline.create_profile'
)
其中條目是獲取該功能的導入路徑。
編輯:鏈接到文檔和設置說明。
但爲什麼這增加了管道,而不是使用post_save回調?後者應該工作,而不管哪個認證後端創建用戶。 – knipknap