code: def _current_ids_subquery(self):
          
          return self.values(*self.model.KEY_FIELDS).annotate(max=models.Max('pk')).values('max')
docs: Internal helper method to return an SQL string that will get the IDs of
          all the current entries (i.e. the most recent entry for each unique set
          of key values). Only useful if KEY_FIELDS is set.