def _get_latest_metric(metric_code):
 try:
  last_metric = Metric.objects.filter(kind__code=metric_code).order_by('-start')[0]
  return last_metric
 except IndexError:
  return None

def _get_latest_metric ( metric_code ) : try : last_metric = Metric . objects . filter ( kind__code = metric_code ) . order_by ( '-start' ) [ 0 ] return last_metric except IndexError : return None
returns the date of the latest metric value .