[Django]-Django: Redirect logged in users from reset password page

4👍

You can override the .dispatch(…) method [Django-doc], this is for example also done in the LogoutView to logout users:

class MyPasswordResetView(PasswordResetView):
    template_name = 'security/reset_password.html'

   def dispatch(self, *args, **kwargs):
       if self.request.user.is_authenticated:
           return redirect('home-page')
       return super().dispatch(*args, **kwargs)

Leave a comment