diff options
| author | levental <levental@fh-brandenburg.de> | 2016-09-19 14:55:18 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-09-27 11:59:00 -0400 |
| commit | 617e36dc1ede2a311dfd03f18432b31cbfe4c0f7 (patch) | |
| tree | 38fd43fc044ff923321b444c292686798dfb17bd /tests/auth_tests/models | |
| parent | f7e91cac689b28fc32ca52cdeac258ec0d58b4fc (diff) | |
Fixed #20705 -- Allowed using PasswordResetForm with user models with an email field not named 'email'.
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() |
