如果当前用户已登录,我正在更改密码。
views.py :
def change_password(request,pk=None):
user = MyUser.objects.get(pk=pk)
if request.method == "POST":
form = PasswordChangeForm(user=user, data=request.POST)
if form.is_valid():
form.save()
update_session_auth_hash(request, form.user)
context = {
'form': form,
'title': _('Password change'),
}
return render(request, "nurse/change_password.html")
else:
form = PasswordChangeForm(user=user)
context = {
'form': form,
'title': _('Password change'),
}
return render(request,"nurse/change_password.html")
该函数工作正常,但在此函数调用之后,我没有在我的html文件中获取user.id。
我做错了什么?