title: Django Unable to login after extending user model and creating the superuser
body: <p>I was able to create extended user with the help of answer received in my previous <a href="https://stackoverflow.com/questions/2511759/after-extending-the-user-model-in-django-how-do-you-create-a-modelform">question</a></p>
  
  <p>I did syncdb and created first superuser, but now I am unable to login. I get error "Please enter the correct username and password for a staff account. Note that both fields may be case-sensitive."
  I did find few similar questions on SO but either they do not have answer or if answer is there I was unable to solve my problem.</p>
  
  <p>Below are my latest code:
  models.py</p>
  
  <pre><code>from django.db import models
  from django.contrib.auth.models import AbstractUser
  from django.conf import settings
  from epi.managers import EmployeeManager
  # Create your models here.
  
  class Employee(AbstractUser):
      emp_id = models.IntegerField('Employee Id', max_length=5,unique=True)
      dob = models.DateField('Date of Birth', null=True,blank=True)
  
      REQUIRED_FIELDS = ['email', 'emp_id']
      objects = EmployeeManager()
  
      def __unicode__(self):
          return self.get_full_name
  
  
  class Department(models.Model):
      name = models.CharField('Department Name',max_length=30, unique=True,default=0)
      def __unicode__(self):
          return self.name
  
  
  class Report(models.Model):
      user = models.ForeignKey(settings.AUTH_USER_MODEL)
      dept = models.ForeignKey(Department, verbose_name="Department")
      report1 = models.ForeignKey(Employee,null=True,blank=True, verbose_name=u'Primary Supervisor',related_name='Primary')
      report2 = models.ForeignKey(Employee,null=True,blank=True, verbose_name=u'Secondary Supervisor',related_name='Secondary')
  
      def __unicode__(self):
          return self.user
  </code></pre>
  
  <p>admin.py</p>
  
  <pre><code>from django.contrib import admin
  from django.contrib.auth.admin import UserAdmin
  from django.contrib.auth.forms import UserChangeForm, UserCreationForm
  from epi.models import Employee
  from django import forms
  from django.contrib.auth.models import Group
  
  
  class EmployeeChangeForm(UserChangeForm):
      class Meta(UserChangeForm.Meta):
          model = Employee
  
  
  class EmployeeCreationForm(UserCreationForm):
      class Meta(UserCreationForm.Meta):
          model = Employee
  
      def clean_username(self):
          username = self.cleaned_data['username']
          try:
              Employee.objects.get(username=username)
          except Employee.DoesNotExist:
              return username
          raise forms.ValidationError(self.error_messages['duplicate_username'])
  
  
  class EmployeeAdmin(UserAdmin):
      form = EmployeeChangeForm
      add_form = EmployeeCreationForm
      fieldsets = UserAdmin.fieldsets + (
          (None, {'fields': ('emp_id', 'dob',)}),
      )
  
  admin.site.register(Employee, EmployeeAdmin)
  admin.site.unregister(Group)
  </code></pre>
  
  <p>managers.py</p>
  
  <pre><code>from django.contrib.auth.models import BaseUserManager
  
  
  class EmployeeManager(BaseUserManager):
      def create_user(self, username,  email,emp_id,  password=None):
          if not username:
              raise ValueError('Employee must have an username.')
          if not email:
              raise ValueError('Employee must have an email address.')
          if not emp_id:
              raise ValueError('Employee must have an employee id')
          user = self.model(username=username, email=self.normalize_email(email), emp_id=emp_id)
          user.set_password(password)
          user.save(using=self._db)
          return user
  
      def create_superuser(self, username,  email, emp_id, password):
          user = self.create_user(username,  email, emp_id, password)
          user.is_admin = True
          user.is_superuser = True
          user.save(using=self._db)
          return user
  </code></pre>
  
  <p>settings.py</p>
  
  <pre><code>"""
  Django settings for employee project.
  
  For more information on this file, see
  https://docs.djangoproject.com/en/1.6/topics/settings/
  
  For the full list of settings and their values, see
  https://docs.djangoproject.com/en/1.6/ref/settings/
  """
  
  # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
  import os
  BASE_DIR = os.path.dirname(os.path.dirname(__file__))
  
  
  # Quick-start development settings - unsuitable for production
  # See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/
  
  # SECURITY WARNING: keep the secret key used in production secret!
  SECRET_KEY = '$@k3%w-f3jbj(y6_fh+me+_)8&amp;z%lt%4u(nyu^xdrn9=%&amp;_!bl'
  
  # SECURITY WARNING: don't run with debug turned on in production!
  DEBUG = True
  
  TEMPLATE_DEBUG = True
  
  ALLOWED_HOSTS = []
  
  
  # Application definition
  
  INSTALLED_APPS = (
      'grappelli',
      'django.contrib.admin',
      'django.contrib.auth',
      'django.contrib.contenttypes',
      'django.contrib.sessions',
      'django.contrib.messages',
      'django.contrib.staticfiles',
      'epi',
      'south',
  )
  
  MIDDLEWARE_CLASSES = (
      'django.contrib.sessions.middleware.SessionMiddleware',
      'django.middleware.common.CommonMiddleware',
      'django.middleware.csrf.CsrfViewMiddleware',
      'django.contrib.auth.middleware.AuthenticationMiddleware',
      'django.contrib.messages.middleware.MessageMiddleware',
      'django.middleware.clickjacking.XFrameOptionsMiddleware',
  )
  
  ROOT_URLCONF = 'employee.urls'
  
  WSGI_APPLICATION = 'employee.wsgi.application'
  
  
  # Database
  # https://docs.djangoproject.com/en/1.6/ref/settings/#databases
  
  DATABASES = {
      'default': {
          'ENGINE': 'django.db.backends.sqlite3',
          'NAME': os.path.join(BASE_DIR, 'employee.db'),
         }
  }
  
  # Internationalization
  # https://docs.djangoproject.com/en/1.6/topics/i18n/
  
  LANGUAGE_CODE = 'en-us'
  
  TIME_ZONE = 'UTC'
  
  USE_I18N = True
  
  USE_L10N = True
  
  USE_TZ = True
  
  
  # Static files (CSS, JavaScript, Images)
  # https://docs.djangoproject.com/en/1.6/howto/static-files/
  
  STATIC_URL = '/static/'
  
  STATICFILES_FINDERS = (
      'django.contrib.staticfiles.finders.AppDirectoriesFinder',
      'django.contrib.staticfiles.finders.FileSystemFinder',
  )
  
  TEMPLATE_CONTEXT_PROCESSORS = (
      "django.contrib.auth.context_processors.auth",
      "django.core.context_processors.request",
      "django.core.context_processors.static",
      "django.core.context_processors.media",
  )
  
  TEMPLATE_DIRS = (
      BASE_DIR + '/templates',)
  
  STATICFILES_DIRS = (
      ('assets', 'F:/djangoenv/testenv1/employee/static'),
        )
  
  AUTH_USER_MODEL = 'epi.Employee'
  
  GRAPPELLI_ADMIN_TITLE = 'MyAdmin'
  
  SESSION_EXPIRE_AT_BROWSER_CLOSE = True
  
  MEDIA_ROOT = BASE_DIR + '/media/'
  
  MEDIA_URL = '/media/'
  </code></pre>