Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from django.db import models
- from django.contrib.auth.models import ( AbstractUser, BaseUserManager )
- class CustomUserModelManager(BaseUserManager):
- pass
- class CustomUser(AbstractUser):
- username = models.CharField(max_length=150, unique=True)
- password = models.CharField(default='', max_length=150)
- email = models.EmailField(max_length=254)
- first_name = models.CharField(max_length=150)
- last_name = models.CharField(max_length=150)
- is_active = models.BooleanField(default=True)
- is_staff = models.BooleanField(default=False)
- is_admin = models.BooleanField(default=False)
- timestamp = models.DateTimeField(auto_now_add=True)
- USERNAME_FIELD = 'username'
- REQUIRED_FIELDS = ['password', 'email']
- def __unicode__(self):
- return self.username
- def __str__(self):
- return self.username
- @property
- def is_active(self):
- return self.is_active
- @property
- def is_staff(self):
- return self.is_staff
- @property
- def is_admin(self):
- return self.is_admin
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement