# settings file:
AUTH_USER_MODEL = 'usercp.Customer'
AUTHENTICATION_BACKENDS = ('usercp.backend.MyAuth', )

# backend.py in usercp (APP) folder
from models import Customer
from django.contrib.auth.hashers import check_password

# Taken from http://www.djangorocks.com/tutorials/creating-a-custom-authentication-backend/creating-a-simple-authentication-backend.html
class MyAuth:

    def authenticate(self, email="", password=""):
        try:
            user = Customer.objects.get(email=email)
            if check_password(password, user.password):
                return user
            else:
                return None
        except Customer.DoesNotExist:
            # No user was found, return None - triggers default login failed
            return None

    # Required for your backend to work properly - unchanged in most scenarios
    def get_user(self, user_id):
        try:
            return Customer.objects.get(pk=user_id)
        except Customer.DoesNotExist:
            return None