Ended up using Tom's method in the end (thanks!) - it seemed more efficient 
than grabbing the user object back out of the database to do a password 
comparison on every save.

On Thursday, 25 October 2012 11:41:54 UTC+1, Tom Evans wrote:
>
> On Wed, Oct 24, 2012 at 10:23 PM, Roarster 
> <ianstra...@gmail.com<javascript:>> 
> wrote: 
> > I'm running a Django 1.4 site and I have some operations I want to 
> perform 
> > if a user changes their password.  I'm using the standard contrib.auth 
> user 
> > accounts with the normal password_change view and I'm not sure if I 
> should 
> > somehow hook into this view or if I should use a signal on post_save for 
> the 
> > user.  If I do use the signal, is it possible to tell when the password 
> has 
> > been changed?  I do feel that if I can use a signal this might be the 
> best 
> > approach since it would handle any other password change mechanisms that 
> I 
> > might add later without any extra work. 
> > 
> > Does anyone have any ideas on the best way to do this? 
> > 
>
> The password_change view takes additional arguments, one of which is 
> 'password_change_form'. The form is responsible for changing the users 
> password, and by default is django.contrib.auth.forms.SetPasswordForm 
> (see docs): 
>
>
> https://docs.djangoproject.com/en/1.4/topics/auth/#django.contrib.auth.views.password_change
>  
>
> The form itself is responsible for changing the users password, so by 
> extending that class and specifying that class to be used, you can 
> hook directly in to the derived class's save() method and perform 
> whatever actions you need to when the password is changed. 
>
> Cheers 
>
> Tom 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/QTvAFTN53TIJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to