[Fixed]-How to ajaxable validate a PasswordChangeForm?

1๐Ÿ‘

โœ…

I think the problem is that django FormView is not compatible with PasswordChangeForm. The form requires the user to be passed to its constructor, but the view will not do that. You could try overriding get_form_kwargs method like this:

class AjaxValidation(generic.edit.FormView):
    # your methods
    def get_form_kwargs(self):
        kwargs = super(AjaxValidation, self).get_form_kwargs()
        kwargs['user'] = self.request.user
        return kwargs

The kwargs will be passed to form constructor and it should work. get_form_class is OK in your main code example

๐Ÿ‘คKarolis Ryselis

Leave a comment