Add custom behavior to PasswordResetView?

Hi,

I haven’t implemented what you describe myself, but here’s a tip that might help:
When I want to figure out what method to override I usually go to the excellent site http://ccbv.co.uk, e. g. http://ccbv.co.uk/passwordresetview. It’s great for getting an overview of a CBV’s methods, and what arguments each method expects.

In your case, you want to add code that is to be run if there was a successful POST request, i. e. the form data were valid. It seems to make sense then to override the form_valid method, e. g.

# inside of your View
def form_valid(self, form):
    # logging code, probably making use of data bound to self.request.user
    return super().form_valid(form)

Note that I haven’t tried this myself, but I think this would be a viable method.

(“ccbv” stands for " Classy Class-Based Views", which helps remembering the URL)

2 Likes