code: def get_deployment_count(self):
          
  
          ret = self.stage_set.annotate(num_deployments=Count('deployment')).aggregate(total_deployments=Sum('num_deployments'))
          return ret['total_deployments']
docs: Utility function to get the number of deployments a given project has