From 98d0ac9dae548805cfebaed7dca06ceffda0e966 Mon Sep 17 00:00:00 2001 From: Caio Ariede Date: Sat, 20 Nov 2010 16:51:59 -0200 Subject: [PATCH] Allow setting a custom user model through SOCIAL_AUTH_MODEL_USER --- social_auth/base.py | 4 ++-- social_auth/models.py | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/social_auth/base.py b/social_auth/base.py index 70495f8..76d152d 100644 --- a/social_auth/base.py +++ b/social_auth/base.py @@ -3,11 +3,11 @@ import os import md5 from django.conf import settings -from django.contrib.auth.models import User from django.contrib.auth.backends import ModelBackend -from .models import UserSocialAuth +from .models import UserSocialAuth, get_user_model +User = get_user_model() class BaseAuth(object): """Base authentication class, new authenticators should subclass diff --git a/social_auth/models.py b/social_auth/models.py index 63cd12b..ffe746d 100644 --- a/social_auth/models.py +++ b/social_auth/models.py @@ -1,7 +1,13 @@ """Social auth models""" from django.db import models -from django.contrib.auth.models import User +from django.conf import settings +def get_user_model(): + """Allow setting a custom (extended) user model""" + _from, _model = getattr(settings, 'SOCIAL_AUTH_MODEL_USER', 'django.contrib.auth.models.User').rsplit('.', 1) + return getattr(__import__(_from, globals(), locals(), [_model], -1), _model) + +User = get_user_model() class UserSocialAuth(models.Model): """Social Auth association model""" -- 2.39.5