I am using a two post_save signal handlers for two different models. On
certain conditions they have to send emails to me and others. At times
one signal is generated, at other times two or even in one instance 4
signals were generated, which results in duplicate and triplicate
emails. Has anyone faced this problem?
--
regards
Kenneth Gonsalves
I didn't really investigate this so I could be wrong, but might be
something worth looking at.
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to django-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>
>
well, in one model I am saving twice - so at least that is logical. But
in the other, there is just one save - no commit=false. I read somewhere
long time back that when a model is updated, django saves it twice. In
which case it would be logical?
>
> On 18 August 2010 16:48, Kenneth Gonsalves <law...@au-kbc.org> wrote:
> > hi,
> >
> > I am using a two post_save signal handlers for two different models. On
> > certain conditions they have to send emails to me and others. At times
> > one signal is generated, at other times two or even in one instance 4
> > signals were generated, which results in duplicate and triplicate
> > emails. Has anyone faced this problem?
> > --
> > regards
> > Kenneth Gonsalves
> >
> > --
> > You received this message because you are subscribed to the Google Groups "Django users" group.
> > To post to this group, send email to django...@googlegroups.com.
> > To unsubscribe from this group, send email to django-users...@googlegroups.com.
> > For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
> >
> >
>
--
regards
Kenneth Gonsalves
Just in case - you have set a dispatch_uid during signal connection
so they're only registered once?
You probably have your signal connections at module scope
(e.g. we tend to do them in apps' __init__.py to make sure they're
connected early), and you don't dispatch_uid them, you'll find that just
by virtue of double imports and whatnot sometimes you get duplicate
registrations which cause them to fire twice.
signals.post_save.connect(_do_thingy, sender=Blah, dispatch_uid="mymodule")
Not all the docs mention dispatch_uid, which doesn't help, it's
mentioned here:
http://code.djangoproject.com/wiki/Signals#Helppost_saveseemstobeemittedtwiceforeachsave
yes - actually there was a double import - I removed it and also added
despatch_uid - looks like the problem is solved
--
regards
Kenneth Gonsalves