Sorry for the confusion but I sent the original link from my mobile
handset which isn't great for copying/pasting/etc.
In another post, we were discussing the issue of ManyToMany updates
[1] and how the signal handler for a model X that has a
ManyToManyField to Y will _not_ have an updated Y. It's not
necessarily a "bug" but its feature that's lacking and it's been in
discussion for many years. Here is the use case from the ticket:
For example, I want to send en e-mail when an Account is created to
Account.email. An account has a ManyToManyField to a Location model
and I want to for whatever reason include the location(s) in the e-
mail. If the location was updated using the Account object, the new
location won't be correct in the e-mail because the save for that
field's model hasn't been called yet (if I understand things
correctly).
The current patch adds a new signal m2m_changed. An "action" argument
is sent to the handler telling it if it is an "add," "remove,"
"clear." This is obviously an addition to the other signals but it
seems rather clunky although Malcolm requested that [2]. and that it
would be better to allow the current signals to be called in a truly
"post_save" context, where the ManyToManyField models have been saved
(where appropriate: this probably only applies to the signals
post_save and maybe post_delete).
I see it has one transaction since there is more than one update going
on the use case, so a signal might be named "post_transaction" and you
receive the saved model that has its ManyToManyField's updated. Now, I
think it's more elegant and natural to just have the post_save (and
maybe post_delete) signal send the model instance with the
ManyToManyFields also saved.
I ran into this problem trying to cache data from the DB after a model
was saved that had ManyToMany fields and it never worked. I don't
think many people run into this so perhaps maybe it isn't pressing, or
maybe it's not possible to do, but the ticket said it was trying to
make it into 1.2. I don't think it addresses the problem with signals
not being able to be fully used and seems like a bandage. Then I think
about GenericForeignKeys where is wouldn't work either. I hope this
clears up the confusion (or reveals my own misunderstanding!).
Cheers,
Ryan
[1]
http://groups.google.com/group/django-users/browse_thread/thread/82d5fb7694dc9c5e/350c941c5f81a22a
[2]
http://groups.google.com/group/django-developers/browse_thread/thread/afe6ad7994d868ba
In Ticket 5390 there are a few patches attached to it