Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
python django用户未使用用户对象进行身份验证_Python_Django_Authentication - Fatal编程技术网

python django用户未使用用户对象进行身份验证

python django用户未使用用户对象进行身份验证,python,django,authentication,Python,Django,Authentication,好的,我面临身份验证的问题 user_profile = UserProfile.objects.get(email="some@email.com") new_password = form.cleaned_data['new_password'] user_profile.user.set_password(new_password) user_profile.user.save() user = authenticate(username=user_profile.user.usernam

好的,我面临身份验证的问题

user_profile = UserProfile.objects.get(email="some@email.com")
new_password = form.cleaned_data['new_password']
user_profile.user.set_password(new_password)
user_profile.user.save()
user = authenticate(username=user_profile.user.username, password=new_password)
print(user)
当我打印用户时,它给出
None


用户未被验证的原因?

来自
django.contrib.auth
的authenticate函数在凭据匹配时返回
django.contrib.auth.models.user
类的实例,如果凭据不匹配则返回None

我猜不存在您提供的用户名和密码的用户。这就是为什么你一无所获

我建议你到壳牌公司去跑步:

from django.contrib.auth.models import User
from django.contrib.auth.hashers import make_password
password = make_password("your_password")
user = User.objects.filter(username="username",password=password)

查看用户持有的密码。

您是否已将用户密码设置为新值?是的,我已完成用户配置文件。用户。设置密码(新密码)并保存了它?是的,我保存了。。我已经更新了问题这里可能有什么问题??