喵吉欧尼酱

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

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
这两段是用于自定义登入 邮箱和账号登入

 

posted on 2017-10-06 17:52  喵吉欧尼酱  阅读(139)  评论(0)    收藏  举报