ITMISS
django.contrib.auth.backends.ModelBackend跟数据库类型没有关系,这是对用户认证用的。默认的认证backend会对帐号密码进行验证。AUTHENTICATION_BACKENDS = {'django.contrib.auth.backends.ModelBackend',}可以自己扩展,比如用手机号也能登录users.views.pyclass CustomBackend(ModelBackend):def authenticate(self, request, username=None, password=None, **kwargs):try:user = User.objects.get(Q(username=username) | Q(mobile=username))if user.check_password(password):return userexcept Exception as e:return None在设置成自定义的backendAUTHENTICATION_BACKENDS = {'users.views.CustomBackend'}