更改密码后无法获取用户ID

时间:2016-06-14 10:40:18

标签: python django python-3.x django-1.9

如果当前用户已登录,我正在更改密码。

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。

我做错了什么?

0 个答案:

没有答案