<noframes id="55z35">
    <address id="55z35"><address id="55z35"></address></address>

      <address id="55z35"><th id="55z35"></th></address>
        <address id="55z35"></address>
        <address id="55z35"><listing id="55z35"><listing id="55z35"></listing></listing></address>
        <address id="55z35"></address>

        蒲公英聯盟提供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

        尚未注冊暢言帳號,請到后臺注冊
        日本一级婬片