]> git.parisson.com Git - django-social-auth.git/commitdiff
Allow setting a custom user model through SOCIAL_AUTH_MODEL_USER
authorCaio Ariede <caio.ariede@gmail.com>
Sat, 20 Nov 2010 18:51:59 +0000 (16:51 -0200)
committerCaio Ariede <caio.ariede@gmail.com>
Sat, 20 Nov 2010 18:51:59 +0000 (16:51 -0200)
social_auth/base.py
social_auth/models.py

index 70495f8db83da36f13f550007e4ae113ff7b58b5..76d152d153b148cd1a83d5d9921ce2b4ed6744fb 100644 (file)
@@ -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
index 63cd12b47b68f5d9f90815a430f02023cf58510a..ffe746d6462b81065dcaf9fe66a058b8123bf215 100644 (file)
@@ -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"""