title: Django ORM get maximum value of a field and corresponding other column values
body: <p>I have a DataFrame:</p>
  
  <pre><code>`exp_no`   'time'   'price'
  </code></pre>
  
  <hr>
  
  <pre><code>  1       0:00:00     20.0
    1       7 days      45.0
    1       15 days     100.0
    2       0:00:00     20.0
    2       7 days      45.0
    2       15 days     100.0
  </code></pre>
  
  <p>The corresponding Django model:</p>
  
  <pre><code>class StData(models.Model):
        exp_no = models.ForeignKey(StIndex, on_delete=models.CASCADE)
        time = models.DateTimeField()
        price = models.DecimalField(max_digits=10, decimal_places=2)   
  </code></pre>
  
  <p>I want to make a smaller table which would have exp_no, max_time and corresponding price such that:</p>
  
  <pre><code> `exp_no`   'time'   'price'
  </code></pre>
  
  <hr>
  
  <pre><code>  1       15 days     100.0
    2       15 days     100.0
  </code></pre>
  
  <p>In pandas, I'd do <code>df.groupby('exp_no')['time', 'price'].max().reset_index()</code>
  to get the desired table.</p>
  
  <p>In Django ORM annotation to get the same result(or Queryset) if I do:</p>
  
  <pre><code>qs.values('exp_no').annotate(max_time=Max('time')).order_by()
  </code></pre>
  
  <p>it gives me exp_no and time, but I want to get the corresponding price as well. I have looked through this answer in SO: <a href="https://stackoverflow.com/questions/19923877/django-orm-get-latest-for-each-group">Django orm get latest for each group</a></p>
  
  <p>But not sure how I get the price. Using Django 2.0 with sqlite3.</p>
  
  <p>I appreciate any help. </p>