Thanks! I put the function just in the file of one of the models (it is used for handling the signal) and it worked perfectly.
I just came to an idea that the pre_init and post_init signals could be used to extend contributed models without modifying their files. The question that cames to my mind is: How to attach an attribute, property or method to an existing Python class? Any examples or directions? Regards, Aidas Bendoraitis [aka Archatas] On 3/7/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > > On Wed, 2007-03-07 at 11:58 +0100, Aidas Bendoraitis wrote: > > I've never used signals before and I think I came to a point when I > > need to start doing that. > > > > What I need is to call some function just after the User is saved. > > > > According to the docs that I found about signals, I should do something > > like: > > > > # --- code --- # > > from django.contrib.auth.models import User > > from django.dispatch import dispatcher > > > > def my_function_to_call(sender, instance, signal, *args, **kwargs): > > pass > > > > dispatcher.connect(my_function_to_call, signal=signals.post_save, > > sender=User) > > > > # --- /code --- # > > > > Where should I put this code, so that I wouldn't need to modify the > > contributed models and the code was read and executed when the user is > > saved? > > You can put the code anywhere you like, providing it will be executed. > One thing to do might be to put an "import signal_hookups" in your > settings.py file and put the dispatch connection in signal.hookups.py. > > Or put it in one of your model's files, if you are going to be using > that model in the process of handling the signal. > > Basically, you just need to put the dispatch call somewhere it will be > executed. The my_function_to_call() function can be anywhere you like; > just make sure you import it wherever you set up the dispatch. > > Regards, > Malcolm > > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---