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