我在settings.py插入这样的:电子邮件身份验证
AUTHENTICATION_BACKENDS = (
'blog.auth.backends.EmailBackend',
'django.contrib.auth.backends.ModelBackend',
)
博客是一个应用程序(正确安装),权威性是博客应用程序的文件夹,backends.py是文件包含此方法:
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
我的问题是:
为什么我得到这个错误? :
ImproperlyConfigured at /signup/
Error importing authentication backend auth.backends: "No module named auth.backends"
而__init__.py在Blog文件夹中吗? – 2010-05-04 17:57:54