I'm currently using Django 1.5 custom user models. Using my code below, how can I add new second type of user?
I want to add a new user like called StandardUser I already have CompanyUser type i.e.
class StandardUser(AbstractEmailUser):
class Meta:
app_label = 'accounts'
But this does not seems to work, how can I achieve this?
Current code below:
class AbstractEmailUser(AbstractBaseUser, PermissionsMixin):
"""
Abstract User with the same behaviour as Django's default User but
without a username field. Uses email as the USERNAME_FIELD for
authentication.
Use this if you need to extend EmailUser.
Inherits from both the AbstractBaseUser and PermissionMixin.
The following attributes are inherited from the superclasses:
* password
* last_login
* is_superuser
"""
email = models.EmailField(_('email address'), max_length=255,
unique=True, db_index=True)
is_staff = models.BooleanField(_('staff status'), default=False,
help_text=_('Designates whether the user can log into this admin '
'site.'))
is_active = models.BooleanField(_('active'), default=True,
help_text=_('Designates whether this user should be treated as '
'active. Unselect this instead of deleting accounts.'))
date_joined = models.DateTimeField(_('date joined'), default=timezone.now)
objects = EmailUserManager()
USERNAME_FIELD = 'email'
REQUIRED_FIELDS = []
class Meta:
abstract = True
class CompanyUser(AbstractEmailUser):
company = models.CharField(max_length=100)
class Meta:
app_label = 'accounts'