kers/users/models.py

25 lines
791 B
Python
Raw Normal View History

2020-07-22 00:51:40 +02:00
from django.contrib.auth.base_user import AbstractBaseUser
2020-07-21 22:24:45 +02:00
from django.db import models
2020-07-22 00:51:40 +02:00
from django.contrib.auth.models import User, PermissionsMixin
from django.utils import timezone
2020-07-21 22:24:45 +02:00
2020-07-22 00:51:40 +02:00
from users.managers import CustomUserManager
2020-07-21 22:24:45 +02:00
2020-07-22 00:51:40 +02:00
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
2020-07-21 22:24:45 +02:00
student_number = models.CharField(max_length=255)
2020-07-22 00:51:40 +02:00
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