def get_deployment_count(self):
        """Utility function to get the number of deployments a given project has"""

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