#33369: Add through_defaults as argument for m2m_changed signal
-------------------------------------+-------------------------------------
     Reporter:  ShmuelTreiger        |                    Owner:  nobody
         Type:  New feature          |                   Status:  new
    Component:  Database layer       |                  Version:  dev
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  m2m_changed          |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by ShmuelTreiger):

 * status:  closed => new
 * resolution:  invalid =>


Comment:

 `domain.policy_set.add(<>)` does not call save() on the m2m model. From
 the documentation here
 
https://docs.djangoproject.com/en/4.0/ref/models/relations/#django.db.models.fields.related.RelatedManager.add

 >Using add() with a many-to-many relationship, however, will not call any
 save() methods (the bulk argument doesn’t exist), but rather create the
 relationships using QuerySet.bulk_create(). If you need to execute some
 custom logic when a relationship is created, listen to the m2m_changed
 signal, which will trigger pre_add and post_add actions.

 I tried `save`, it didn't work, so I found the documentation which told me
 to use `m2m_changed`.

 I suppose instead of `add`, I could do
 `Domain_Policy_m2m.objects.create(<>)` but that's just seems less than
 ideal.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33369#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/071.b2b2f314516aa5319d1649ff83973ee7%40djangoproject.com.

Reply via email to