diff options
| author | Gavin Wahl <gwahl@fusionbox.com> | 2013-05-29 16:11:26 -0600 |
|---|---|---|
| committer | Gavin Wahl <gwahl@fusionbox.com> | 2013-05-29 16:11:26 -0600 |
| commit | 01ae881bb4d13d6fe1b77f8758cc0bc72786cfaa (patch) | |
| tree | b7624718818a81ac117a5663747b8cd3e4d372ce | |
| parent | 1fdc3d256d5d515bd0b4646ad57f231a2359e0cd (diff) | |
Don't hard-code class names when calling static methods
normalize_email should be called on the instance, not the class. This
has the same effect normally but is more helpful to subclassers. When
methods are called directly on the class, subclasses can't override
them.
| -rw-r--r-- | django/contrib/auth/models.py | 2 | ||||
| -rw-r--r-- | django/contrib/auth/tests/test_custom_user.py | 2 | ||||
| -rw-r--r-- | docs/topics/auth/customizing.txt | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/django/contrib/auth/models.py b/django/contrib/auth/models.py index 5709d25d7f..798cc805a0 100644 --- a/django/contrib/auth/models.py +++ b/django/contrib/auth/models.py @@ -177,7 +177,7 @@ class UserManager(BaseUserManager): now = timezone.now() if not username: raise ValueError('The given username must be set') - email = UserManager.normalize_email(email) + email = self.normalize_email(email) user = self.model(username=username, email=email, is_staff=False, is_active=True, is_superuser=False, last_login=now, date_joined=now, **extra_fields) diff --git a/django/contrib/auth/tests/test_custom_user.py b/django/contrib/auth/tests/test_custom_user.py index 0d324f0953..a3a159880a 100644 --- a/django/contrib/auth/tests/test_custom_user.py +++ b/django/contrib/auth/tests/test_custom_user.py @@ -21,7 +21,7 @@ class CustomUserManager(BaseUserManager): raise ValueError('Users must have an email address') user = self.model( - email=CustomUserManager.normalize_email(email), + email=self.normalize_email(email), date_of_birth=date_of_birth, ) diff --git a/docs/topics/auth/customizing.txt b/docs/topics/auth/customizing.txt index 9a8bab947c..bc021b14ad 100644 --- a/docs/topics/auth/customizing.txt +++ b/docs/topics/auth/customizing.txt @@ -939,7 +939,7 @@ authentication app:: raise ValueError('Users must have an email address') user = self.model( - email=MyUserManager.normalize_email(email), + email=self.normalize_email(email), date_of_birth=date_of_birth, ) |
