You have to replace exist create_user pipeline if you want custom user creation behavior, but your code looks weird if you need just change default User model then it's redundant, you need just set AUTH_USER_MODEL
and that's it.
If you need extract some extra data for new user, then add something like this:
def save_profile(backend, user, response, *args, **kwargs):
if backend.name == "facebook":
save_facebook_profile(user, response, **kwargs)
elif backend.name == "google-oauth2":
save_google_profile(user, response, **kwargs)
else:
return # Unspecified backend
user.social = True
user.save()
def save_google_profile(user, response, **kwargs):
if response.get("image"):
if not user.avatar_image and not user.avatar_url:
user.avatar_url = response.get("image").get("url")
# Handle other fields
and in settings:
SOCIAL_AUTH_PIPELINE = (
'social_auth.pipeline.social_auth.social_details',
'social_auth.pipeline.social_auth.social_uid',
'social_auth.pipeline.social_auth.auth_allowed',
'social_auth.pipeline.social_auth.social_user',
'social_auth.pipeline.user.get_username',
'social_auth.backends.pipeline.user.create_user',
'accounts.pipeline.save_profile', # here is new pipeline behavior
'social_auth.pipeline.social_auth.associate_user',
'social_auth.pipeline.social_auth.load_extra_data',
'social_auth.pipeline.user.user_details',
)
for more details: http://python-social-auth-docs.readthedocs.io/en/latest/pipeline.html