Normalize the email address by lowercasing the domain part of it.
(cls, email)
| 21 | class BaseUserManager(models.Manager): |
| 22 | @classmethod |
| 23 | def normalize_email(cls, email): |
| 24 | """ |
| 25 | Normalize the email address by lowercasing the domain part of it. |
| 26 | """ |
| 27 | email = email or "" |
| 28 | try: |
| 29 | email_name, domain_part = email.strip().rsplit("@", 1) |
| 30 | except ValueError: |
| 31 | pass |
| 32 | else: |
| 33 | email = email_name + "@" + domain_part.lower() |
| 34 | return email |
| 35 | |
| 36 | def get_by_natural_key(self, username): |
| 37 | return self.get(**{self.model.USERNAME_FIELD: username}) |
no outgoing calls