title: Access ForeignKey set directly in template in Django
body: <p>I have this simplified model:</p>
  
  <pre><code>class Item(models.Model):
      name = models.CharField(max_length=120)
  
  class ItemImage(models.Model):
      image = models.ImageField(upload_to='upload_dir')
      item = models.ForeignKey(Item)
  </code></pre>
  
  <p>An <code>Item</code> can have many <code>ItemImages</code>. I also have a template rendering the following data set from the view:</p>
  
  <pre><code>items = Item.objects.all()
  </code></pre>
  
  <p>So now I would want to do something like this in the template:</p>
  
  <pre><code>{% for item in items %}
  &lt;div&gt;
      {{ item.name }}&lt;br&gt;
      &lt;img src="{{ item.itemimage_set.all()[0] }}"&gt;
  &lt;/div&gt;
  {% endfor %}
  </code></pre>
  
  <p>But obviously that's not possible. Not from the template directly, at least.</p>
  
  <p>What is the proper way to get the equivalent of the first image inside the template?</p>