title: How to display a list of objects containing many-to-many relations in Django template?
body: <p>I have the following models:</p>
  
  <pre><code>class Tag(models.Model):
    name = models.CharField(max_length=20)
  
  class Entry(models.Model):
    title = models.CharField(max_length=100)
    date = models.DateField()
    tags = models.ManyToManyField(Tag)
  </code></pre>
  
  <p>In a view I create a list of Entry object and want to show the elements in the template:</p>
  
  <pre><code>   {% for entry in entries %}
       {{ entry.title }}
       {{ entry.date }}
     &lt;!--  {% for tag in entry.tags %} {{ tag }} {% endfor %} --&gt;
     {% endfor %}
  </code></pre>
  
  <p>And with this template code it generates the following TemplateSyntaxError pointing to the template's first line (for tag):</p>
  
  <p><strong>Caught TypeError while rendering: 'ManyRelatedManager' object is not iterable</strong></p>
  
  <p>The entries variable is a list:</p>
  
  <pre><code>entries = Entry.objects.filter(user=user_id)
  entries = list(entries)
  entries.sort(key=lambda x: x.id, reverse=False)
  </code></pre>
  
  <p>Do you know what can be the problem here and how to resolve this issue?</p>
  
  <p>I'm new to Django, so any suggestions how to debug the templates may be helpful.</p>
  
  <p><strong>Update</strong></p>
  
  <p>I get the same error even with this template:</p>
  
  <pre><code>{% for entry in entries.all %}
  &lt;!-- everything is commented out here --&gt;
  {% endfor %}
  </code></pre>