Django 自定义身份验证函数不接受第三个参数
尝试使用以下准则编写自己的自定义身份验证后端: 我想用以下元素实现身份验证功能:Django 自定义身份验证函数不接受第三个参数,django,authentication,Django,Authentication,尝试使用以下准则编写自己的自定义身份验证后端: 我想用以下元素实现身份验证功能: 用户名 密码 验证码 我将函数定义如下: def authenticate(self, username=None, password = None, verification_code = None): ... 但是,我只为用户名和密码获取了一个值,而没有为验证代码获取值 登录表单如下所示: <form id="login-form" method="POST"> {% csrf
def authenticate(self, username=None, password = None, verification_code = None):
...
但是,我只为用户名
和密码
获取了一个值,而没有为验证代码
获取值
登录表单如下所示:
<form id="login-form" method="POST">
{% csrf_token %}
...
<input id="user_name" type="text" class="form-control" name="username" placeholder="Email Address" required="" autofocus="" />
<input id="password" type="password" class="form-control" name="password" placeholder="Password" required=""/>
<input id="verification_code" type="text" class="form-control" name="verification_code" placeholder="Verification Code" required=""/>
<button class="btn btn-lg btn-primary btn-block" type="submit">Login</button>
</form>
{%csrf_令牌%}
...
登录
任何帮助都将不胜感激:)从Django 1.11开始,您还必须包括
请求
参数:
在Django 1.11中更改:request
参数被添加到authenticate()
中,对不接受它的后端的支持将在Django 2.1中删除
从Django 1.11开始,您还必须包括
请求
参数:
在Django 1.11中更改:request
参数被添加到authenticate()
中,对不接受它的后端的支持将在Django 2.1中删除