Re: Added signals that runs when adding an object to a Many-To-One relation

2017-02-06 Thread Oskar Persson
That is correct, yes. Den måndag 6 februari 2017 kl. 21:51:52 UTC+1 skrev Tim Graham: > > I was unclear. My point is that by listening to a Manager.add() signal, > your cache invalidation handler won't catch cases where other code calls > QuerySet.update(). If update signals were implemented

Re: Added signals that runs when adding an object to a Many-To-One relation

2017-02-06 Thread Tim Graham
I was unclear. My point is that by listening to a Manager.add() signal, your cache invalidation handler won't catch cases where other code calls QuerySet.update(). If update signals were implemented and your code listened to that, there would be no need to add or listen to a Manager.add()

Re: Added signals that runs when adding an object to a Many-To-One relation

2017-02-06 Thread Oskar Persson
Yes, my PR does just that, it sends the signal when bulk=True i.e. when an QuerySet.update() will be used. And a more general update() signal I guess would have to look through the fields that it's updating and check if its a foreign key and then send the signals for those elements some how

Re: Added signals that runs when adding an object to a Many-To-One relation

2017-02-06 Thread Tim Graham
Tell me if I'm wrong because I haven't worked through things in detail but it seems to me that an "add" signal wouldn't catch the case where objects are added or delete using QuerySet.update(). For the update() signal to process objects of B, it looks like you would check the 'update_fields"

Re: Added signals that runs when adding an object to a Many-To-One relation

2017-02-06 Thread Oskar Persson
My specific need for this at the moment is that i need to do some computation (including cache invalidation) whenever objects of model A are added to/deleted from model B. This could easily be done if I had signals for these events. And the only thing that I need to know is what instance of B

Re: Added signals that runs when adding an object to a Many-To-One relation

2017-02-06 Thread Tim Graham
Could you describe your use case in more detail? I feel like it would result in less code duplication to write signal handlers for Model.save() and QuerySet.update() rather than for remove(), clear(), add(), and set() (the more high level ways that an object could be updated). I'm not happy to

Re: Added signals that runs when adding an object to a Many-To-One relation

2017-02-06 Thread Oskar Persson
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

Re: Added signals that runs when adding an object to a Many-To-One relation

2017-02-06 Thread 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

Re: Added signals that runs when adding an object to a Many-To-One relation

2017-02-05 Thread 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,

Re: Added signals that runs when adding an object to a Many-To-One relation

2017-02-03 Thread Oskar Persson
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

Re: Added signals that runs when adding an object to a Many-To-One relation

2017-02-03 Thread 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

Re: Added signals that runs when adding an object to a Many-To-One relation

2017-02-03 Thread Paul Egges
Good to know. Thanks, Paul On Fri, Feb 3, 2017 at 10:03 AM, Oskar Persson wrote: > No, the save method isn't called unless you specify bulk=False > > >

Re: Added signals that runs when adding an object to a Many-To-One relation

2017-02-03 Thread Oskar Persson
No, the save method isn't called unless you specify bulk=False Den fredag 3 februari 2017 kl. 17:53:04 UTC+1 skrev mtnpaul: > > I thought a Many-To-One would not require an

Re: Added signals that runs when adding an object to a Many-To-One relation

2017-02-03 Thread Paul Egges
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 wrote: > Hi everyone. > > I've created a

Added signals that runs when adding an object to a Many-To-One relation

2017-02-03 Thread Oskar Persson
Hi everyone. I've created a pull request (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