Hi all,
I'm having trouble detecting changes that happen to a M2M field behind the scenes: as a result of one of the *referenced objects being deleted*
I'm using Django 1.3.1 with PostgreSQL 8
Let's say we have the following simple proof of concept models:
class Topping(models.Model):
name = models.CharField()
class Pizza(models.Model):
name = models.CharField()
toppings = models.ManyToManyField(Topping, null=true, blank=true)
And this data established using those models:
TOPPING
id=1, name="Pepperoni"
id=2, name="Onion"
id=3, name="Mushroom"
PIZZA
id=1, name="foopizza"
toppings=1,2,3
Known Facts:
1. Deleting any Topping object (for example, deleting id=1, name="Pepperoni") also removes it from foopizza.toppings. Good.
2. No m2m_changed signal is sent when 1 (above happens). BAD.
How do I tie into "topping *object* was deleted (no longer for sale), perform custom code on ALL Pizza objects that referenced it" ?
Register a post_delete signal for Topping? How do I refer to or find the Pizza objects that referred to it?