views:

120

answers:

1

I have inserted this in settings.py:

AUTHENTICATION_BACKENDS = (
'blog.auth.backends.EmailBackend',
'django.contrib.auth.backends.ModelBackend',

)

blog is an application ( correctly installed ), auth is a folder in blog application, backends.py is the file that contain this method:

from django.contrib.auth.backends import ModelBackend
from django.core.validators import email_re
from django.contrib.auth.models import User


class EmailBackend(ModelBackend):

    def authenticate(self, username=None, password=None):
        if email_re.search(username):
            try:
                user = User.objects.get(email=username)
                if user.check_password(password):
                    return user
            except User.DoesNotExist:
                return None
        return None

My question is:

Why I get this error ? :

ImproperlyConfigured at /signup/
Error importing authentication backend auth.backends: "No module named auth.backends" 
+3  A: 

You should make sure to have an __init__.py in all of the used folders (blog and auth)!

lazerscience