2016-03-22 141 views
2

爲什麼下面的代碼導致我的用戶在輸入新的有效密碼時被註銷?Django密碼更改

@login_required 
def change_password(request): 
    pass_form = PasswordChangeForm(user=request.user) 
    if request.method == 'POST': 
     pass_form = PasswordChangeForm(user=request.user, data=request.POST) 
     if pass_form.is_valid(): 
      pass_form.save() 
      return render(request,'coursework/profile.html', 
             {'pass_form' : pass_form, 
             'pass_msg' : 'Password Updated'}) 
    return render(request, 'coursework/new_password_form.html', 
           {'form': pass_form}) 

回答