kers/users/models.py
2020-07-22 00:51:40 +02:00

24 lines
791 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
student_number = models.CharField(max_length=255)
real_name = models.CharField(max_length=100)
date_joined = models.DateTimeField(default=timezone.now)
USERNAME_FIELD = 'username'
REQUIRED_FIELDS = ['zeus_id']
objects = CustomUserManager()
def __str__(self):
return self.username