Add User model and set AUTH_USER_MODEL

This commit is contained in:
Jean Lionel Ndabaga 2024-03-07 09:00:07 +02:00
parent 11a1d7bb8e
commit 1a1cebd94e
2 changed files with 22 additions and 1 deletions

View file

@ -1,3 +1,22 @@
from django.db import models
from django.contrib.auth.models import AbstractBaseUser
# Create your models here.
class User(AbstractBaseUser):
email = models.EmailField(unique=True)
username = models.CharField(max_length=100, unique=True)
date_joined = models.DateTimeField(auto_now_add=True)
last_login = models.DateTimeField(auto_now=True)
is_admin = models.BooleanField(default=False)
is_staff = models.BooleanField(default=False)
is_active = models.BooleanField(default=True)
is_superuser = models.BooleanField(default=False)
def __str__(self):
return f'{self.username} - {self.email}'
def has_perm(self, perm, obj=None):
return self.is_admin
def has_module_perms(self, app_label):
return True

View file

@ -67,6 +67,8 @@ TEMPLATES = [
},
]
AUTH_USER_MODEL = 'api.User'
WSGI_APPLICATION = 'buffer_clone_backend.wsgi.application'