title: Django filter child by parent
body: <p>I'm trying to filter children by its parent in my templates. Example being I have houses that are displayed and want to display their amenities(children) along with them. When I try and do so each house list all amenities for every house. How would I make is so that I list a house and only its amenities?</p>
  
  <p>Here are my models:</p>
  
  <pre><code>class Home(models.Model):
      name = models.CharField(max_length=255)
      photo = models.ImageField()
  
      def __str__(self):
          return self.name
  
  
  class Amenities(models.Model):
      home = models.ForeignKey(Home)
      amenities = models.CharField(max_length=255)
  </code></pre>
  
  <p>In my views I am trying to filter the child by its parent: </p>
  
  <pre><code>def index(request):
      home = Home.objects.filter()
      amenities = Amenities.objects.filter(home=home)
  
      return render(request, 'home/home.html', {'home': home, 'amenities': amenities})
  </code></pre>
  
  <p>In my template I am try and loop through each home and their amenities like so:</p>
  
  <pre><code>    {% for house in home %}
      &lt;div class="row"&gt;
          &lt;div class="col-md-6 portfolio-item"&gt;
              &lt;a href="house1.html"&gt;
                  &lt;img class="img-responsive" src=" media/{{ house.photo }}" alt=""&gt;
              &lt;/a&gt;
              &lt;h3&gt;
                  &lt;a href="house1.html"&gt;House&lt;/a&gt;
              &lt;/h3&gt;
              &lt;ul&gt;
                  {% for i in amenities %}
                  &lt;li&gt;{{ i.amenities }}&lt;/li&gt;
                  {% endfor %}
              &lt;/ul&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      {% endfor %} 
  </code></pre>
  
  <p>thank you</p>