class Foo(models.Model):
name = models.CharField(max_length=256)
total = models.SmallIntegerField()
availability = models.SmallIntegerField()
class Bar(models.Model):
somthing = ...
foo = models.ForeignKey(Foo, blank=True, null=True)
Everytime you save Bar, and the user selected a Foo, it must decrease availability by 1. And when the user deselects an option from Foo, it adds 1 to availability. So if you choose another option, that one gets 1 minus, and the deselected one 1 plus.
Are there signals that I can use to detect that the foreign key is selected or not selected ?