Hi everyone, Django version 1.10.7, I have a problem where sometimes my receiving `m2m_changed` signal on a ManyToMany field has `pk_set` empty.
The model m2m part (note it's a `self` reference): class Profile(TimeStampedModel): following = models.ManyToManyField( "self", verbose_name=_("Following"), related_name="followers" ) Signal beginning part with logger: @receiver(m2m_changed, sender=Profile.following.through) def profile_following_change(sender, instance, action, pk_set, **kwargs ): logger.debug("profile_following_change - sender %s, instance %s, action %s, pk_set %s, kwargs: %s", sender, instance, action, pk_set, kwargs) Below an example log line with `pk_set` containing the added primary key: DEBUG:socialhome:profile_following_change - sender <class 'socialhome.users.models.Profile_following'>, instance Profile A (profil...@a.domain.tld), action post_add, pk_set {2}, kwargs: { 'signal': <django.db.models.signals.ModelSignal object at 0x7fa73e033908>, 'model': <class 'socialhome.users.models.Profile'>, 'using': 'default', 'reverse': False } And an example with an empty `pk_set`. DEBUG:socialhome:profile_following_change - sender <class 'socialhome.users.models.Profile_following'>, instance Profile B (profil...@b.domain.tld), action post_add, pk_set set(), kwargs: { 'model': <class 'socialhome.users.models.Profile'>, 'reverse': False, 'using': 'default', 'signal': <django.db.models.signals.ModelSignal object at 0x7f001c173908> } The two saves are both from the same code, using the following line. Note this code runs in an RQ background process, should that matter: profile.following.add(user.profile) Why is the `pk_set` sometimes empty, any ideas? Note that both `Profile` objects also exist before the RQ job is processed (event is triggered by doing a "follow" in the UI). Also of note, added object *is* found in the ManyToMany field after the operation. Thankful of any ideas, Br, Jason Robinson https://jasonrobinson.me -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/4e409d43-f079-4031-8c1b-7b54e07bf3b6%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.