- if form.is_valid():
- form.save()
- messages.add_message(request, messages.INFO, _("Profile has been changed."))
- return http.HttpResponseRedirect('/accounts/')
-
- return account_profile(request, basic_form=form)
-
-@require_POST
-@login_required
-def account_change_password(request):
- form = UserPasswordForm(request.POST)
-
- if form.is_valid():
- request.user.set_password(form.cleaned_data['new_password'])
- request.user.save()
- update_session_auth_hash(request, request.user)
-
- messages.add_message(request, messages.INFO, _("Password has been changed."))
- return http.HttpResponseRedirect('/accounts/')
-
- return account_profile(request, pass_form=form)
+ def form_valid(self, form):
+ retval = super().form_valid(form)
+ messages.add_message(self.request, messages.INFO, _("Profile has been changed."))
+ return retval