26 lines
763 B
Python
26 lines
763 B
Python
|
from django.contrib.auth.base_user import AbstractBaseUser
|
||
|
from django.db import models
|
||
|
from django.contrib.auth.models import User, PermissionsMixin
|
||
|
from django.utils import timezone
|
||
|
|
||
|
from users.managers import CustomUserManager
|
||
|
|
||
|
|
||
|
class CustomUser(AbstractBaseUser, PermissionsMixin):
|
||
|
zeus_id = models.IntegerField(unique=True, null=True)
|
||
|
is_staff = models.BooleanField(default=False)
|
||
|
username = models.CharField(max_length=50, unique=True) # zeus username
|
||
|
|
||
|
date_joined = models.DateTimeField(default=timezone.now)
|
||
|
|
||
|
USERNAME_FIELD = 'username'
|
||
|
REQUIRED_FIELDS = ['zeus_id']
|
||
|
|
||
|
objects = CustomUserManager()
|
||
|
|
||
|
def __str__(self):
|
||
|
return self.username
|
||
|
|
||
|
def __repr__(self):
|
||
|
return "<User: {}>".format(self.username)
|