Kaydet (Commit) 01ae881b authored tarafından Gavin Wahl's avatar Gavin Wahl

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.
üst 1fdc3d25
...@@ -177,7 +177,7 @@ class UserManager(BaseUserManager): ...@@ -177,7 +177,7 @@ class UserManager(BaseUserManager):
now = timezone.now() now = timezone.now()
if not username: if not username:
raise ValueError('The given username must be set') 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, user = self.model(username=username, email=email,
is_staff=False, is_active=True, is_superuser=False, is_staff=False, is_active=True, is_superuser=False,
last_login=now, date_joined=now, **extra_fields) last_login=now, date_joined=now, **extra_fields)
......
...@@ -21,7 +21,7 @@ class CustomUserManager(BaseUserManager): ...@@ -21,7 +21,7 @@ class CustomUserManager(BaseUserManager):
raise ValueError('Users must have an email address') raise ValueError('Users must have an email address')
user = self.model( user = self.model(
email=CustomUserManager.normalize_email(email), email=self.normalize_email(email),
date_of_birth=date_of_birth, date_of_birth=date_of_birth,
) )
......
...@@ -939,7 +939,7 @@ authentication app:: ...@@ -939,7 +939,7 @@ authentication app::
raise ValueError('Users must have an email address') raise ValueError('Users must have an email address')
user = self.model( user = self.model(
email=MyUserManager.normalize_email(email), email=self.normalize_email(email),
date_of_birth=date_of_birth, date_of_birth=date_of_birth,
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment