invalid_models.py 618 B

1234567891011121314151617181920
  1. from django.contrib.auth.models import AbstractBaseUser, UserManager
  2. from django.db import models
  3. class CustomUserNonUniqueUsername(AbstractBaseUser):
  4. """
  5. A user with a non-unique username.
  6. This model is not invalid if it is used with a custom authentication
  7. backend which supports non-unique usernames.
  8. """
  9. username = models.CharField(max_length=30)
  10. email = models.EmailField(blank=True)
  11. is_staff = models.BooleanField(default=False)
  12. is_superuser = models.BooleanField(default=False)
  13. USERNAME_FIELD = 'username'
  14. REQUIRED_FIELDS = ['email']
  15. objects = UserManager()