我已将此插入到settings.py中:
AUTHENTICATION_BACKENDS = (
'blog.auth.backends.EmailBackend',
'django.contrib.auth.backends.ModelBackend',
)
blog是一个应用程序(正确安装),auth是blog应用程序中的一个文件夹,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"