diff --git a/api/models.py b/api/models.py index 71a8362..c844fcb 100644 --- a/api/models.py +++ b/api/models.py @@ -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 diff --git a/buffer_clone_backend/settings.py b/buffer_clone_backend/settings.py index f53486e..a92293c 100644 --- a/buffer_clone_backend/settings.py +++ b/buffer_clone_backend/settings.py @@ -67,6 +67,8 @@ TEMPLATES = [ }, ] +AUTH_USER_MODEL = 'api.User' + WSGI_APPLICATION = 'buffer_clone_backend.wsgi.application'