Commits

dzhibas  committed e4bad34 Draft

Preparing for django 1.5 and custom user model

  • Participants
  • Parent commits 27bccd1

Comments (0)

Files changed (7)

File registration/backends/simple/__init__.py

 from django.conf import settings
 from django.contrib.auth import authenticate
 from django.contrib.auth import login
-from django.contrib.auth.models import User
+from django.contrib.auth import get_user_model
 
 from registration import signals
 from registration.forms import RegistrationForm
 
+User = get_user_model()
+
 
 class SimpleBackend(object):
     """

File registration/forms.py

 
 """
 
-
-from django.contrib.auth.models import User
+from django.contrib.auth import get_user_model
 from django import forms
 from django.utils.translation import ugettext_lazy as _
 
+User = get_user_model()
 
 # I put this on all required fields, because it's easier to pick up
 # on them with CSS or JavaScript if they have a class of "required"

File registration/models.py

 import re
 
 from django.conf import settings
-from django.contrib.auth.models import User
+from django.contrib.auth import get_user_model
 from django.db import models
 from django.db import transaction
 from django.template.loader import render_to_string
     datetime_now = datetime.datetime.now
 
 
+User = get_user_model()
+
 SHA1_RE = re.compile('^[a-f0-9]{40}$')
 
 

File registration/tests/backends.py

 
 from django.conf import settings
 from django.contrib import admin
-from django.contrib.auth.models import User
+from django.contrib.auth import get_user_model
 from django.contrib.sessions.middleware import SessionMiddleware
 from django.contrib.sites.models import Site
 from django.core import mail
 from registration.backends.simple import SimpleBackend
 from registration.models import RegistrationProfile
 
+User = get_user_model()
+
 
 class _MockRequestClient(Client):
     """

File registration/tests/forms.py

-from django.contrib.auth.models import User
+from django.contrib.auth import get_user_model
 from django.test import TestCase
 
 from registration import forms
 
+User = get_user_model()
+
 
 class RegistrationFormTests(TestCase):
     """

File registration/tests/models.py

 import re
 
 from django.conf import settings
-from django.contrib.auth.models import User
+from django.contrib.auth import get_user_model
 from django.contrib.sites.models import Site
 from django.core import mail
 from django.core import management
 
 from registration.models import RegistrationProfile
 
+User = get_user_model()
+
 
 class RegistrationModelTests(TestCase):
     """

File registration/tests/views.py

 import datetime
 
 from django.conf import settings
-from django.contrib.auth.models import User
+from django.contrib.auth import get_user_model
 from django.core import mail
 from django.core.urlresolvers import reverse
 from django.test import TestCase
 from registration import forms
 from registration.models import RegistrationProfile
 
+User = get_user_model()
+
 
 class RegistrationViewTests(TestCase):
     """