hello all,

i'm trying to follow the official doc:
https://docs.djangoproject.com/en/1.3/topics/signals/

I wrote:

@receiver(post_save, sender=MyModel)
def my_callback(sender, **kwargs):
    if 'created' in kwargs:
        if kwargs['created']:
            print "sender", sender
            print "Request finished!"
            if kwargs['instance']:
                mymodel = kwargs['instance']
                print "mymodel ", mymodel

post_save.connect(my_callback, dispatch_uid="my_unique_identifier")

i'm working thru the admin page. I want callback() called only once,
when i add an object MyModel
But logs on the server show the following:

sender <class 'myproj.models.MyModel'>
Request finished!
mymodel  corpus: jpg methode: Methode object status: W cpu_time: None
mem_used: None created_on: 2011-06-21 19:14:05.246381
sender <class 'myproj.models.MyModel'>
Request finished!
mymodel  corpus: jpg methode: Methode object status: W cpu_time: None
mem_used: None created_on: 2011-06-21 19:14:05.246381
sender <class 'django.contrib.admin.models.LogEntry'>
Request finished!
mymodel  LogEntry object


So callback() is called 3 times, ignoring the receiver decorator.
Neither the test on 'created' variable doesn't limit calls.

What am i missing?

thanks in advance for help,


-- 
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 
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