title: Django query with order_by, distinct and limit on Postgresql
body: <p>I have the following :</p>
  
  <pre><code>class Product(models.Model):
      name = models.CharField(max_length=255)
  
  class Action(models.Model):
      product = models.ForeignKey(Product)
      created_at = models.DateTimeField(auto_now_add=True)
  </code></pre>
  
  <p>I would like to retrieve the 10 most recent actions ordered by created_at DESC with distinct products.</p>
  
  <p>The following is close to the result but still misses the ordering:</p>
  
  <pre><code>Action.objects.all().order_by('product_id').distinct('product_id')[:10]
  </code></pre>