mirror of
https://github.com/TurTaskProject/TurTaskWeb.git
synced 2025-12-19 14:04:07 +01:00
29 lines
992 B
Python
29 lines
992 B
Python
from django.db import models
|
|
from django.utils import timezone
|
|
from django.utils.translation import gettext_lazy as _
|
|
from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin
|
|
|
|
from .managers import CustomAccountManager
|
|
|
|
|
|
class CustomUser(AbstractBaseUser, PermissionsMixin):
|
|
# User fields
|
|
email = models.EmailField(_('email address'), unique=True)
|
|
username = models.CharField(max_length=150, unique=True)
|
|
first_name = models.CharField(max_length=150, blank=True)
|
|
start_date = models.DateTimeField(default=timezone.now)
|
|
about = models.TextField(_('about'), max_length=500, blank=True)
|
|
is_staff = models.BooleanField(default=False)
|
|
is_active = models.BooleanField(default=True)
|
|
|
|
# Custom manager
|
|
objects = CustomAccountManager()
|
|
|
|
# Fields for authentication
|
|
USERNAME_FIELD = 'email'
|
|
REQUIRED_FIELDS = ['username', 'first_name']
|
|
|
|
def __str__(self):
|
|
# String representation of the user
|
|
return self.username
|