1. 程式人生 > >django 重新學習 前段頁面配置(五)

django 重新學習 前段頁面配置(五)

spa try 登入 exc object ati profile users ews

setting配置

class CustomBackend(ModelBackend):
    def authenticate(self, username=None, password=None, **kwargs):
        try:
            user=UserProfile.objects.get(username=username)
            if user.check_password(password): #這密碼是重載Mode裏面的內置方法  
                return user
        except Exception as e:
            
return None

AUTHENTICATION_BACKENDS=(
    users.views.CustomBackend,
)  
# Application definition
這兩段是用於自定義登入 郵箱和賬號登入

django 重新學習 前段頁面配置(五)