AttributeError: 'UserManager' object has no attribute 'create_superuser'

I supposed that you have Django 1.8. Here is what you have to do to create your own models which inherit of AbstractUser model.

In your models :

from django.contrib.auth.models import AbstractUser
from django.db import models

class User(AbstractUser):
  pass

Your User model will automatically inherit of the UserManager of AbstractUser then you don't have to write : objects = YourUserManager() unless you want to extend it. In this case, you can do this :

from django.contrib.auth.models import AbstractUser, UserManager as AbstractUserManager
from django.db import models

class UserManager(AbstractUserManager):
  pass

class User(AbstractUser):
    objects = UserManager()

Define the User model in settings.py used in your Django apps :

# <module_name>.<user_model_name>
AUTH_USER_MODEL = 'user.User'

Now, when you want to import your user model in an other app to use it, use settings.AUTH_USER_MODEL. here is an example :

from django.db import models
from django.conf import settings

class Token(models.Model):
    user = models.ForeignKey(settings.AUTH_USER_MODEL)

Read the right Django documentation for more information : Extending the existing user model

Sunny Prakash

Try this and replace the fields according to your requirements:

class UserManager(BaseUserManager):

    def create_user(self, email, password=None,is_active=True,is_staff=False,is_admin=False):
        """
        Creates and saves a User with the given email and password.
        """
        if not email:
            raise ValueError('Users must have an email address')

        user = self.model(
            email=self.normalize_email(email),
        )

        user.set_password(password)
        user.save(using=self._db)
        return user

    def create_staffuser(self, email, password):
        """
        Creates and saves a staff user with the given email and password.
        """
        user = self.create_user(
            email,
            password=password,
        )
        user.staff = True
        user.save(using=self._db)
        return user

    def create_superuser(self, email, password):
        """
        Creates and saves a superuser with the given email and password.
        """
        user = self.create_user(
            email,
            password=password,
        )
        user.staff = True
        user.admin = True
        user.save(using=self._db)
        return user