diff options
Diffstat (limited to 'tests/auth_tests/models')
| -rw-r--r-- | tests/auth_tests/models/with_custom_email_field.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/auth_tests/models/with_custom_email_field.py b/tests/auth_tests/models/with_custom_email_field.py new file mode 100644 index 0000000000..a98b02b8f1 --- /dev/null +++ b/tests/auth_tests/models/with_custom_email_field.py @@ -0,0 +1,23 @@ +from django.contrib.auth.base_user import AbstractBaseUser +from django.contrib.auth.models import BaseUserManager +from django.db import models + + +class CustomEmailFieldUserManager(BaseUserManager): + def create_user(self, username, password, email): + user = self.model(username=username) + user.set_password(password) + user.email_address = email + user.save(using=self._db) + return user + + +class CustomEmailField(AbstractBaseUser): + username = models.CharField(max_length=255) + password = models.CharField(max_length=255) + email_address = models.EmailField() + is_active = models.BooleanField(default=True) + + EMAIL_FIELD = 'email_address' + + objects = CustomEmailFieldUserManager() |
