title: How can I make a Django query for the first occurrence of a foreign key in a column?
body: <p>Basically, I have a table with a bunch of foreign keys and I'm trying to query only the first occurrence of a particular key by the "created" field. Using the Blog/Entry example, if the Entry model has a foreign key to Blog and a foreign key to User, then how can I construct a query to select all Entries in which a particular User has written the first one for the various Blogs?</p>
  
  <pre><code>class Blog(models.Model):
      ...
  
  class User(models.Model):
      ...
  
  class Entry(models.Model): 
      blog = models.Foreignkey(Blog)
      user = models.Foreignkey(User)
  </code></pre>
  
  <p>I assume there's some magic I'm missing to select the first entries of a blog and that I can simple filter further down to a particular user by appending:</p>
  
  <pre><code>query = Entry.objects.magicquery.filter(user=user)
  </code></pre>
  
  <p>But maybe there's some other more efficient way. Thanks!</p>