{{{
class MyModel(models.Model):
likes = models.ForeignKey(User)
}}}
Now if I add a user to the likes field as below,
{{{
myObj.likes.add(user)
}}}
my m2m_changed receiver method will be called in signals module with
action post_add and pk_set as the User ID. If I try to add likes again
with the same user and same above method, now post_add again called with
pk_set as empty.
And when I try to remove the user as below,
{{{
myObj.likes.remove(user)
}}}
m2m_changed receiver method is called with action post_remove and pk_set
as User ID. And if I try to remove the same user again, this time also
m2m_changed receiver method is called. But this time pk_set contains the
User ID.
For post_add, pk_set will be empty after first add. Subsequent calls will
always set pk_set as empty. But for post_remove pk_set will always
contains pk_set value. Why it is that?
I'm calculating points based on this like events. Now I need to make sure
ManyToMany relationship exist before adding/substracting points by making
an extra call to database. If somehow we could know if the relation
already added/removed from m2m_changed signal, it will be great.
--
Ticket URL: <https://code.djangoproject.com/ticket/30287>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* resolution: => duplicate
Comment:
https://code.djangoproject.com/ticket/29615
--
Ticket URL: <https://code.djangoproject.com/ticket/30287#comment:1>