And we could also maybe add signals similar to pre_add and post_add that are sent when calling remove() and clear() on a relation set, getting a bit closer to QuerySet.update()
Den måndag 6 februari 2017 kl. 10:22:27 UTC+1 skrev Oskar Persson: > > No, if the QuerySet.update() signals were to be implemented then these > signals wouldn't be needed anymore. However, since there currently aren't > any solutions for the QuerySet.update() signals that aren't a performance > concern then the add signals could be a first step there. They don't solve > all the problems that the update signals does but they solve some of them > without having any real impact on performance. > > Den måndag 6 februari 2017 kl. 03:00:18 UTC+1 skrev Tim Graham: >> >> Since you created a ticket [0], I assume you feel there is value is >> adding this signal even if the QuerySet.update() signal is added? Could you >> explain the rationale? >> >> What are the performance implications of additional (possibly redundant) >> signals? As Aymeric said on the pull request, "Performance should be a >> consideration here, pre_init and post_init is a very expensive historical >> mistake." >> >> [0] https://code.djangoproject.com/ticket/27809 >> >> On Friday, February 3, 2017 at 12:29:04 PM UTC-5, Oskar Persson wrote: >>> >>> It would. Though that seems like its trying to solve a bigger issue >>> since then you probably *need* the updated objects, which I'm not >>> including >>> >>> Den fredag 3 februari 2017 kl. 18:21:55 UTC+1 skrev Tim Graham: >>>> >>>> #21461 proposes to add signals for QuerySet.update(). Would this solve >>>> your use case? >>>> >>>> https://code.djangoproject.com/ticket/21461 >>>> >>>> On Friday, February 3, 2017 at 12:14:23 PM UTC-5, mtnpaul wrote: >>>>> >>>>> Good to know. >>>>> >>>>> Thanks, >>>>> >>>>> Paul >>>>> >>>>> >>>>> On Fri, Feb 3, 2017 at 10:03 AM, Oskar Persson <oskar....@polken.se> >>>>> wrote: >>>>> >>>>>> No, the save method isn't called unless you specify bulk=False >>>>>> <https://docs.djangoproject.com/en/1.10/ref/models/relations/#django.db.models.fields.related.RelatedManager.add> >>>>>> >>>>>> Den fredag 3 februari 2017 kl. 17:53:04 UTC+1 skrev mtnpaul: >>>>>>> >>>>>>> I thought a Many-To-One would not require an intermediate table, so >>>>>>> it would be caught by pre-save and post-save on the object containing >>>>>>> the >>>>>>> Foreign Key. Is that not true? >>>>>>> >>>>>>> >>>>>>> Paul >>>>>>> >>>>>>> On Fri, Feb 3, 2017 at 8:28 AM, Oskar Persson <oskar....@polken.se> >>>>>>> wrote: >>>>>>> >>>>>>>> Hi everyone. >>>>>>>> >>>>>>>> I've created a pull request (8018) >>>>>>>> <https://github.com/django/django/pull/8018> that adds the signals >>>>>>>> pre_add and post_add that are triggered when adding an object to a >>>>>>>> Many-To-One relation. The reason for this PR is to provide a simple >>>>>>>> (is >>>>>>>> there any other?) way to run custom code when ever adding an object to >>>>>>>> a >>>>>>>> Many-To-One relation. There already exists a signal for >>>>>>>> Many-To-Many >>>>>>>> <https://docs.djangoproject.com/en/1.10/ref/signals/#m2m-changed> >>>>>>>> fields so why not for Many-To-One? >>>>>>>> >>>>>>>> What are your thoughts on this? >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> Thanks >>>>>>>> >>>>>>>> Oskar Persson >>>>>>>> >>>>>>>> -- >>>>>>>> You received this message because you are subscribed to the Google >>>>>>>> Groups "Django developers (Contributions to Django itself)" group. >>>>>>>> To unsubscribe from this group and stop receiving emails from it, >>>>>>>> send an email to django-develop...@googlegroups.com. >>>>>>>> To post to this group, send email to django-d...@googlegroups.com. >>>>>>>> Visit this group at >>>>>>>> https://groups.google.com/group/django-developers. >>>>>>>> To view this discussion on the web visit >>>>>>>> https://groups.google.com/d/msgid/django-developers/249d697b-f030-4112-a192-2c8510461f5b%40googlegroups.com >>>>>>>> >>>>>>>> <https://groups.google.com/d/msgid/django-developers/249d697b-f030-4112-a192-2c8510461f5b%40googlegroups.com?utm_medium=email&utm_source=footer> >>>>>>>> . >>>>>>>> For more options, visit https://groups.google.com/d/optout. >>>>>>>> >>>>>>> >>>>>>> -- >>>>>> You received this message because you are subscribed to the Google >>>>>> Groups "Django developers (Contributions to Django itself)" group. >>>>>> To unsubscribe from this group and stop receiving emails from it, >>>>>> send an email to django-develop...@googlegroups.com. >>>>>> To post to this group, send email to django-d...@googlegroups.com. >>>>>> Visit this group at https://groups.google.com/group/django-developers >>>>>> . >>>>>> To view this discussion on the web visit >>>>>> https://groups.google.com/d/msgid/django-developers/e6e9a557-44f0-4489-bc11-baae40e35930%40googlegroups.com >>>>>> >>>>>> <https://groups.google.com/d/msgid/django-developers/e6e9a557-44f0-4489-bc11-baae40e35930%40googlegroups.com?utm_medium=email&utm_source=footer> >>>>>> . >>>>>> >>>>>> For more options, visit https://groups.google.com/d/optout. >>>>>> >>>>> >>>>> -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To post to this group, send email to django-developers@googlegroups.com. Visit this group at https://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/de171a25-4a00-4c00-925b-a2e285ef7418%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.