models.py
class Region(models.Model):
name = models.CharField(blank=False, unique=True)
count = models.IntegerField(blank=True, null=True) # This should be the occurrence count in ETF
class ETF(models.Model):
ticker = models.CharField()
region = models.ManyToManyField(Region, blank=True)
Example: If there is 100 ETF objects in ETF model have U.S.A. as region, then count field in U.S.A. object in Region model should be 100.
How do I automatically update the count field in Region Model everytime there are changes in the database? Sorry if there is duplicate question,
I just can't find the keywords to search for the solution.