码迷,mamicode.com
首页 > 其他好文 > 详细

django 重新学习 前段页面配置(五)

时间:2017-10-06 18:35:34      阅读:96      评论:0      收藏:0      [点我收藏+]

标签:get   log   ati   custom   self   nbsp   django   tin   check   

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 重新学习 前段页面配置(五)

标签:get   log   ati   custom   self   nbsp   django   tin   check   

原文地址:http://www.cnblogs.com/Mjonj/p/7631886.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!