gpt4 book ai didi

python - Django 中的 PASSWORD_HASHERS 设置

转载 作者:太空狗 更新时间:2023-10-29 17:55:10 24 4
gpt4 key购买 nike

每当我尝试通过任何用户登录时,我都会遇到错误错误

Unknown password hashing algorithm 'sahar'. Did you specify it in the PASSWORD_HASHERS setting?

Views.Py

def Login(request):
state = "Please log in below..."
username = password = ''
if request.method == 'POST':
username = request.POST['username']
password = request.POST['password']
user = authenticate(username=username, password=password)
if user is not None:
if user.is_active:
login(request, user)
return HttpResponseRedirect('/profile/')
else:
return render_to_response('auth.html',RequestContext(request))

else:
return render_to_response('auth.html',RequestContext(request))
else:
return render_to_response('auth.html',RequestContext(request)

最佳答案

这意味着有一个纯文本'sahar'存储为尝试登录的用户帐户的密码。
在 Admin 或 manage.py shell

中更新用户密码
user = User.objects.get(username=username)

# use set_password method
user.set_password('sahar')
user.save()

# INSTEAD OF
user.password = 'sahar'
user.save()

同时检查您的其他 View 以更正 user.password = '...'User.objects.create(password='...') 用法.

关于python - Django 中的 PASSWORD_HASHERS 设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10246463/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com