• <blockquote id="0wwma"></blockquote>
  • <blockquote id="0wwma"></blockquote>
    <samp id="0wwma"><s id="0wwma"></s></samp>
    <input id="0wwma"></input>
  • <samp id="0wwma"><input id="0wwma"></input></samp>
  • 蒲公英聯盟提供ghost win10,ghost win7,xp,裝機純凈版,64位旗艦版,綠色軟件,免費軟件下載基地!

    當前位置:主頁 > 教程 > 服務器類 >

    ) 自定義認證類 在login app下創建auth.py文件

    來源:蒲公英系統┆發布時間:2018-10-31 05:07┆點擊:

    首先創建一個新的login app,用來存放認證用到代碼

    python manage.py startapp login

    修改settings.py中的認證項

    AUTHENTICATION_BACKENDS = ( 'login.auth.UsernamePasswordAuth', )

    自定義認證類

    在login app下創建auth.py文件,內容如下

    #coding:utf-8 from django.contrib.auth.models import User class UsernamePasswordAuth(object): def authenticate(self, username=None, password=None): print("UsernamePasswordAuth.authenticate") try: user = User.objects.get(username__iexact=username) if user.check_password(password): return user except User.DoesNotExist: return None def get_user(self, user_id): print("UsernamePasswordAuth.get_user") try: user = User.objects.get(pk=user_id) return user except User.DoesNotExist: return None

    尚未注冊暢言帳號,請到后臺注冊
    人与动人物xxxx毛片
  • <blockquote id="0wwma"></blockquote>
  • <blockquote id="0wwma"></blockquote>
    <samp id="0wwma"><s id="0wwma"></s></samp>
    <input id="0wwma"></input>
  • <samp id="0wwma"><input id="0wwma"></input></samp>