Create a gist now

Instantly share code, notes, and snippets.

from django.db import models
from django.contrib.auth.models import AbstractBaseUser
from django.core.urlresolvers import reverse
from .managers import UserManager
class User(AbstractBaseUser):
email = models.EmailField(max_length=255, unique=True)
first_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50)
is_active = models.BooleanField(default=True)
is_admin = models.BooleanField(default=False)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now_add=True)
objects = UserManager()
REQUIRED_FIELDS = ['first_name', 'last_name']
def get_full_name(self):
return '%s %s' % (self.first_name, self.last_name)
def get_short_name(self):
def __unicode__(self):
def has_perm(self, perm, obj=None):
return True
def has_module_perms(self, app_label):
return True
def is_staff(self):
return self.is_admin
def is_employed(self):
return self.position != None
def company(self):
if self.is_employed:
return None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment