I would like to do something if the django user password has been set or update. So i trigger signals.post_save with the User class, like this:
=============================================================================== from django.db.models import signals from django.dispatch import dispatcher def update(sender, instance, signal, *args, **kwargs): user_obj = instance ... user_obj.message_set.create(message="Updated!") dispatcher.connect(update, signal=signals.post_save, sender=User) =============================================================================== But my function 'update' is not only called if the user password changed. The problem is, in the User model exists e.g. 'last_login'. So the save method called every time, the user logged in :( One idea is this: =============================================================================== old_passwords = {} def save_old_pass(sender, instance, signal, *args, **kwargs): user_obj = instance old_pass = user_obj.password old_passwords[user_obj] = old_pass def update(sender, instance, signal, *args, **kwargs): user_obj = instance new_password = user_obj.password if user_obj in old_passwords and old_passwords[user_obj] == new_password: # Nothing to change return ... user_obj.message_set.create(message="Updated!") from django.db.models import signals from django.dispatch import dispatcher dispatcher.connect(save_old_pass, signal=signals.post_init, sender=User) dispatcher.connect(update, signal=signals.post_save, sender=User) =============================================================================== This works, but save_old_pass() would be often called, if the user is logged in. So it's not a really good idea. Any better ideas? -- Mfg. Jens Diemer ---- A django powered CMS: http://www.pylucid.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---