title: django authenticate() for custom user model
body: <p>Below is my custom user model:</p>
  
  <pre><code> class CUserManager(BaseUserManager):
  
          def _create_user(self, email, first_name, password,
                           is_staff, is_superuser, **extra_fields):
              """
          Creates and saves a User with the given email and password.
          """
          now = timezone.now()
          if not email:
              raise ValueError('The given email must be set')
          email = self.normalize_email(email)
          user = self.model(email=email,
                            first_name = first_name,
                            is_staff=is_staff, is_active=False,
                            is_superuser=is_superuser, last_login=now,
                            date_joined=now, **extra_fields)
          user.set_password(password)
          user.save(using=self._db)
          return user
  
      def create_user(self, email, first_name, password=None, **extra_fields):
          return self._create_user(email, first_name, password, False, False,
                                   **extra_fields)
  
      def create_superuser(self, email, first_name, password, **extra_fields):
          return self._create_user(email, first_name, password, True, True,
                                   **extra_fields)
  
  
  class CUser(AbstractBaseUser, PermissionsMixin):
      email = models.EmailField(_('email address'), max_length=254, unique=True)
      first_name = models.CharField(_('first name'), max_length=30)
      last_name = models.CharField(_('last name'), max_length=30, blank=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=False,
          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)
      last_updated = models.DateTimeField(_('last updated'), default=timezone.now)
  
      objects = CUserManager()
  
      USERNAME_FIELD = 'email'
      REQUIRED_FIELDS = ['first_name', 'last_name']
  </code></pre>
  
  <p>It creates a new user correctly. But when I try to authenticate the user from shell or from views, the authenticate() function doesn't work for users having <code>is_active=False</code>.</p>
  
  <pre><code>&gt;&gt;&gt; from django.contrib.auth import get_user_model, auhtenticate
  &gt;&gt;&gt; u = get_user_model()
  &gt;&gt;&gt; authenticate(username='abc@gmail.com', password='abc)
  </code></pre>
  
  <p>The above line returns nothing if the user is inactive but returns the user object otherwise.
  I don't understand why its returning nothing for inactive users.</p>