title: getting foreign key value without fetching the entire object?
body: <p>say I have these models:
  <code><pre>
  class Parent(models.Model):
      slug = models.SlugField()<br>
  class Child(models.Model):
      slug = models.SlugField()
      parent = models.ForeignKey('Parent')
  </pre></code></p>
  
  <p>I want to create a <code>dict</code>:
  <code><pre>
  {x.parent.pk : x.slug for x in Child.objects.all()}
  </pre></code>
  this code generates a separate database query for each iteration. just to get the <code>Parent</code> object, just to get its primary key. which is right there in the <code>Child</code> object to begin with! I do not need anything from the parent, just its primary key. How do I get the value of the underlying foreign key?</p>
  
  <p>(yes, I know that I can use <code>select_related()</code> to get rid of these extra queries, but my question is not about that.)</p>
  
  <p>thanks!</p>