models.py 583 B

123456789101112131415161718192021
  1. # This Source Code Form is subject to the terms of the Mozilla Public
  2. # License, v. 2.0. If a copy of the MPL was not distributed with this
  3. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
  4. from django.db import models
  5. try:
  6. from django.contrib.auth.models import AbstractBaseUser
  7. except ImportError:
  8. AbstractBaseUser = object
  9. class CustomUser(AbstractBaseUser):
  10. USERNAME_FIELD = 'email'
  11. email = models.EmailField(unique=True, db_index=True)
  12. def get_full_name(self):
  13. return self.email
  14. def get_short_name(self):
  15. return self.email