Suppose i have :
class Album(models.Model): photos = models.ManyToManyField(\'myapp.Photo\') photo_count = models.IntegerField(default = 0) class P
You can use django's signals and write a signal handler that will increment the counter using the m2m_changed signal:
m2m_changed
https://docs.djangoproject.com/en/dev/ref/signals/#m2m-changed