123456789101112131415161718192021222324252627282930313233 |
- from django.db import models
- from django.utils.translation import gettext_lazy as _
- from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin
- from django.utils import timezone
- from .managers import UserManager
- class User(AbstractBaseUser, PermissionsMixin):
- first_name = models.CharField(_("first name"), max_length=150, blank=True)
- last_name = models.CharField(_("last name"), max_length=150, blank=True)
- email = models.EmailField(_("email address"), unique=True)
- is_staff = models.BooleanField(
- _("staff status"),
- default=False,
- help_text=_("Designates whether the user can log into this admin site."),
- )
- is_active = models.BooleanField(
- _("active"),
- default=True,
- help_text=_(
- "Designates whether this user should be treated as active. " "Unselect this instead of deleting accounts."
- ),
- )
- date_joined = models.DateTimeField(_("date joined"), default=timezone.now)
- USERNAME_FIELD = "email"
- objects = UserManager() # Here
- class Meta:
- verbose_name = _("user")
- verbose_name_plural = _("users")
|