3 回答

TA貢獻1887條經驗 獲得超5個贊
所以我通過這里的文件解決了我自己的問題:https ://docs.djangoproject.com/en/2.1/topics/auth/customizing/
我所要做的就是 auth_backend.py 中的 authetnicate 函數
def authenticate(self, username=None):
至
def authenticate(self, request, username=None):
在文檔中它說您還可以將類聲明更改為不包含 ModelBackend,但它可以以任何方式工作。

TA貢獻1788條經驗 獲得超4個贊
您可以嘗試避免使用默認后端嗎?
改變
AUTHENTICATION_BACKENDS = [
# auth_backend.py implementing Class PasswordlessAuthBackend inside yourapp folder
'yourapp.auth_backend.PasswordlessAuthBackend',
# Default authentication of Django
'django.contrib.auth.backends.ModelBackend',
]
至
AUTHENTICATION_BACKENDS = [
# auth_backend.py implementing Class PasswordlessAuthBackend inside yourapp folder
'yourapp.auth_backend.PasswordlessAuthBackend',
]

TA貢獻1797條經驗 獲得超6個贊
您在 settings.py 中的身份驗證后端路徑無效
yourapp.auth_backend.YourAuth
應該
yourapp.auth_backend.PasswordlessAuthBackend
添加回答
舉報