social auth した時は前述の Extended User model の Profile が追加されないので、pipeline で Profile を登録する処理を追加する。
python_social_auth (django_social_auth では無い)
参考
http://python-social-auth.readthedocs.org/en/latest/index.html
https://github.com/omab/python-social-auth/blob/master/examples/django_example/example/app/pipeline.py
http://stackoverflow.com/questions/16002576/django-social-auth-multiple-account-association
settings.py
——
SOCIAL_AUTH_PIPELINE = (
'social.pipeline.social_auth.social_details',
'social.pipeline.social_auth.social_uid',
'social.pipeline.social_auth.auth_allowed',
'social.pipeline.social_auth.social_user',
'social.pipeline.user.get_username',
'social.pipeline.mail.mail_validation', # メールのvalidationなくても設定しておいて良さそう。
'social.pipeline.user.create_user',
'account.pipeline.createProfile', # 追加処理
'social.pipeline.social_auth.associate_user', # これが無いとsocial_auth_user に登録されなかった。
#'social.pipeline.debug.debug', # debug用
#'social.pipeline.social_auth.load_extra_data', # 今回はなくても大丈夫だった。
#'social.pipeline.user.user_details',# 今回はなくても大丈夫だった。
#'social.pipeline.debug.debug' # debug用
)
——
account/pipeline.py
——
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from .models import Profile
def createProfile(user, is_new=False, *args, **kwargs):
if is_new:
profile = Profile.objects.create(user=user) # Profile モデルを登録する。
——