model
class Doctor(models.Model): ...tons of fields def no_of_ratings(self): ratings = Rating.objects.filter(doctor=self) return len(ratings)