views:

6

answers:

0

This is pretty covered, but I'm still stucked here.

I made a change password form, as you can see:

class ChangePassForm(forms.Form):

    old_password  = forms.CharField(min_length = 3, widget = forms.PasswordInput)
    new_password1 = forms.CharField(min_length = 3, widget = forms.PasswordInput)
    new_password2 = forms.CharField(min_length = 3, widget = forms.PasswordInput)    

    def __init__(self, user=None, *args, **kwargs):
        if user:
            self.user = user
        super(ChangePassForm, self).__init__(*args, **kwargs)

And my view is like this:

def v_changepass(request):

    #... 
    if request.method == 'POST':
        user = request.user
        form = ChangePassForm(request.POST, user)
        if form.is_valid():  
            #...

So, when I try to enter with the values, the form.is_valid() raises an error:

Exception Type: AttributeError

Exception Value:'User' object has no attribute 'get'

I need the request.user instance to check if the old_password is correct by the method user.check_password(). Any idea about what to do?