Hello Stackoverflow community.
Where is the best place to implement LOGOUT function in PasswordChangeView
I tried
class PasswordCorrectionView(SuccessMessageMixin, LoginRequiredMixin, PasswordChangeView):
template_name = "admin/password_change.html”
form_class = PwdChgForm
def post(self, request, *args, **kwargs):
logout(request) # here
return PasswordChangeView.post(self, request, *args, **kwargs)
but it rises:
NotImplementedError at /account/password/change
Django doesn't provide a DB representation for AnonymousUser.
That's reasonable cos I cant save AnonymousUser password anyway.
So question is what method is the best one to override here in PasswordChangeView???
Or second option override some method in the forms:
class PwdChgForm(PasswordChangeForm):
def save(self, commit=True):
self.user.is_activated = False
user_registrated.send(PwdChgForm, instance=self.user) # signal to the email sender
PasswordChangeForm.save(self, commit=True)
I need user to logout after he has chaged his password (then confirm it via email, etc) All this work except LOGOUT