title: How to make Django Queryset that selects records with max value within a group
body: <p>Here is my Django class:</p>
  
  <pre><code>class MyClass(models.Model):
      my_integer = models.IntegerField()
      created_ts = models.DateTimeField(default=datetime.utcnow, editable=False)
  </code></pre>
  
  <p>I would like to retrieve the instances of <code>MyClass</code> that have the latest <code>created_ts</code> for each unique value of <code>my_integer</code>. I cannot figure out how to do it.</p>
  
  <p>Can someone show my how to do it? </p>