'Validates that the two password inputs match.'

def clean_password2(self):

    if ('password1' in self.cleaned_data):
        if (self.cleaned_data['password1'] == self.cleaned_data['password2']):
            self.password = self.cleaned_data['password2']
            self.cleaned_data['password'] = self.cleaned_data['password2']
            return self.cleaned_data['password2']
        else:
            del self.cleaned_data['password2']
            raise forms.ValidationError(self.fields['password2'].error_messages['nomatch'])
    else:
        return self.cleaned_data['password2']
