title: Django template, loop through items if their id is equal to parent loop name
body: <p>I'm trying to loop through different Zones and then show the items which are part of this zone</p>
  
  <p>Zone is a model, has a name and a ForeignKey. Planche is a model which has Zone as ForeignKey.</p>
  
  <p>I'm looping through zones to display each zone. In that loop I'm looping all Planches and would like to display only the ones that have Zone as a ForeignKey.</p>
  
  <pre><code>class Zones(models.Model):
      name = models.CharField(max_length=30)
      genre = models.ForeignKey(ZoneTypes, on_delete=models.CASCADE)
  
      def __str__(self):
          return self.name
  
  class Planche(models.Model):
      pzone = models.ForeignKey(Zones, on_delete=models.CASCADE)
      ref = models.CharField(max_length=5, default="1")
      length = models.IntegerField()
      width = models.IntegerField()
      orientation = models.CharField(max_length=30)
  
      def __str__(self):
          return self.ref
  </code></pre>
  
  <p>Template</p>
  
  <pre><code>&lt;div&gt;
       &lt;h1&gt;&lt;a href="/"&gt;My list of planches&lt;/a&gt;&lt;/h1&gt;
  &lt;/div&gt;
  {% for z in zones %}
      &lt;div&gt;
          &lt;h2&gt;&lt;a href="/zone/{{ z.name }}"&gt;Zone name: {{ z.name }}&lt;/a&gt;&lt;/h2&gt;
          {% for p in planches %}
          {% if p.pzone == z.name }
          &lt;h1&gt;&lt;a href="planche/{{ planche.ref }}"&gt;Ref: {{ p.ref }}&lt;/a&gt;&lt;/h1&gt;
          &lt;p&gt;Length: {{ p.length }} - Width: {{ p.width }}&lt;/p&gt;
          &lt;p&gt;Orientation: {{ p.orientation }}
          {% endif %}
          {% endfor %}
      &lt;/div&gt;
  {% endfor %}
  </code></pre>
  
  <p>{% if p.pzone = z.name %} returns False,
  They both return the same string if I just display them {{ p.pzone }} and {{ z.name }} but I guess they aren't the same data type. I tried converting them to strings in a {% with %} statement but I keep failing</p>