﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
31981	many_to_many add() does not trigger post_save signal for the through class	Kurt Wheeler	nobody	"I have a many-to-many relationship on my organization model: https://github.com/AlexsLemonade/resources-portal/blob/dev/api/resources_portal/models/organization.py#L50. As you can see, I specify `through=""OrganizationUserAssociation""`, and that class is defined here: https://github.com/AlexsLemonade/resources-portal/blob/dev/api/resources_portal/models/associations/organization_user_association.py

In a branch I am working on, I am adding a post-save signal to OrganizationUserAssociation. What I have found is that this isn't called when `organization.members.add(user)` is called.

I can't actually tell if this is a bug or just poorly documented. The only documentation I can find for the add() method is here: https://docs.djangoproject.com/en/3.1/topics/db/examples/many_to_many/ and it only shows the method being used for a single object. I think the post_save signal isn't being triggered because add() is doing a bulk update instead of creating the through class and saving that? Does add() handle multiple objects, is that why bulk update is being used? I can't actually find any documentation that indicates either way.

However, it makes sense to me that if add() is called with a single object, and there is a `through` class for the many-to-many field, then the `through` class should be used to create the relationship.

It seems like now I have to go through my code and find everywhere I called add() and do it the less convenient way. (The unfortunate thing is, that add() isn't that much more convenient than creating the association, so I wish I had just been warned so I could avoid it altogether.)"	Uncategorized	closed	Database layer (models, ORM)	3.1	Normal	invalid			Unreviewed	0	0	0	0	0	0
