title: Creating a custom login for user changed the login for my Admin. How to prevent that?
body: <p>I am creating a web application where users have to register themselves and create profiles. I am using the "AbstractBaseUser" class provided by Django, as I wanted to add some other fields. Now, when a user logs in, I want the login credentials to be the Mobile number and the password. I created a custom authentication function for this and registered it in my settings.py. The problem is this changed the login to my admin sit, which I want to remain the same. </p>
  
  <p>I followed the tutorial for add custom fields to User from this <a href="http://blackglasses.me/2013/09/17/custom-django-user-model/" rel="nofollow">link</a></p>
  
  <p>My models.py:</p>
  
  <pre><code>from django.db import models
  from django.contrib.auth.models import AbstractBaseUser
  from django.contrib.auth.models import UserManager
  
  
  
  class userInfo(AbstractBaseUser):
  
      email = models.EmailField('Email address', unique=True,)
      Mobile = models.CharField(max_length=15, unique=True,)
      Address = models.CharField(max_length=500)
      Landmark = models.CharField(max_length=50)
      Status = models.BooleanField(default=False)
      is_active = models.BooleanField(default=True)
      is_admin = models.BooleanField(default=False)
  
      USERNAME_FIELD = 'Mobile' 
  
      def __unicode__(self):
          return self.get_username()
  </code></pre>
  
  <p>views.py for login page:</p>
  
  <pre><code>import datetime
  from .forms import userInfoForm, LoginForm
  from django.shortcuts import render, render_to_response
  from .models import userInfo, orderHistory
  from django.http import HttpResponseRedirect, HttpResponse
  from django.template import RequestContext, loader
  from django.contrib.auth import login as django_login, authenticate, logout as django_logoutdef Login(request):
  
  """
  Log in view
  """
  if request.method == 'POST':
      form = LoginForm(data=request.POST)
      print ("Step 1")
      if form.is_valid():
          print ("Step 2")
          user = authenticate(Mobile=request.POST['username'], password=request.POST['password'])
          print ("Step 3")
          if user is None:
              print("No valid user")
          if user is not None:
              print ("Step 3.10")
              if user.is_active:
                  print ("Step 4")
                  django_login(request, user)
                  print ("Step 5")
                  return redirect('/i/Home')
  else:
      form = LoginForm()
  return render_to_response('loginpage.html', {
      'form': form,
  }, context_instance=RequestContext(request))`
  </code></pre>
  
  <p>forms.py:</p>
  
  <pre><code>from django import forms 
  from .models import userInfo, orderHistory  
  from django.forms import ModelForm
  
  
  class LoginForm(forms.Form):
  """
  Login form
  """
  Mobile = forms.CharField(widget=forms.TextInput)
  password = forms.CharField(widget=forms.PasswordInput())
  
  class Meta:
      fields = ['Mobile', 'password']        `
  </code></pre>
  
  <p>The backend I created:</p>
  
  <pre><code>from django.conf import settings
  from django.contrib.auth.models import check_passwor
  from .models import userInfo
  
  class EmailAuthBackend(object):
      """
      A custom authentication backend. Allows users to log in using their            email address.
      """
  
  def authenticate(self, Mobile=None, password=None):
      """
      Authentication method
      """
      try:
          user = userInfo.objects.get(Mobile=Mobile)
          if user.check_password(password):
              return user
      except userInfo.DoesNotExist:
          return None
  
  def get_user(self, user_id):
      try:
          user = userInfo.objects.get(pk=user_id)
          if user.is_active:
              return user
          return None
      except userInfo.DoesNotExist:
          return None
  </code></pre>
  
  <p>And finally the changes I made to settings.py: </p>
  
  <pre><code>AUTH_USER_MODEL = 'Registration.userInfo'
  AUTHENTICATION_BACKENDS = ['Registration.authBackend.EmailAuthBackend', ]
  </code></pre>