title: Django: Distinct foreign keys
body: <pre><code>class Log:
   project = ForeignKey(Project)
   msg = CharField(...)
   date = DateField(...)
  </code></pre>
  
  <p>I want to select the four most recent Log entries where each Log entry must have a unique project foreign key. I've tries the solutions on google search but none of them works and the django documentation isn't that very good for lookup..</p>
  
  <p>I tried stuff like:</p>
  
  <pre><code>Log.objects.all().distinct('project')[:4]
  Log.objects.values('project').distinct()[:4]
  Log.objects.values_list('project').distinct('project')[:4]
  </code></pre>
  
  <p>But this either return nothing or Log entries of the same project..</p>
  
  <p>Any help would be appreciated!</p>