title: How To Access Many to Many Attribute in Django
body: <p>I am very new to web development and I have created a sample project using Django.  So far I have a Django powered page that displays the contents of one of my database's model objects which is called Publications.  The code I have in my view template is:</p>
  
  <pre><code>&lt;html&gt;&lt;head&gt;&lt;title&gt;Publications&lt;/title&gt;&lt;/head&gt;
  &lt;body&gt;
  &lt;h1&gt;Publications&lt;/h1&gt;
  &lt;ul&gt;
  {% for publication in publication_list %}
  &lt;li&gt;{{ publication.title }} &lt;/li&gt;
  {% endfor %}
  &lt;/ul&gt;
  &lt;/body&gt;&lt;/html&gt;
  </code></pre>
  
  <p>This works fine, but now I would like to access and display a many to many attribute on Publications called Tags.  I have tried adding another for tag as follows:</p>
  
  <pre><code>&lt;html&gt;&lt;head&gt;&lt;title&gt;Publications&lt;/title&gt;&lt;/head&gt;
  &lt;body&gt;
  &lt;h1&gt;Publications&lt;/h1&gt;
  &lt;ul&gt;
  {% for publication in publication_list %}
  &lt;li&gt;{{ publication.title }} &lt;/li&gt;
  {% for tag in publication_list.tags %}
  &lt;li&gt;{{ tag.title }} &lt;/li&gt;
  {% endfor %}
  {% endfor %}
  &lt;/ul&gt;
  &lt;/body&gt;&lt;/html&gt;
  </code></pre>
  
  <p>I realize this is quite wrong, but I don't see how to access the Tags model. For reference, my function for displaying the publications in the view is:</p>
  
  <pre><code>def display_publications(request):
      publication_list = Publication.objects.order_by('title')[:10]
      return render(request, 'publications.html', {'publication_list': publication_list})
  </code></pre>
  
  <p>And my Publications and Tag Models are:</p>
  
  <pre><code>class Tag(models.Model):
      title = models.CharField(max_length=50)
  
  class Publication(models.Model):
      title = models.CharField(max_length=200)
      tags = models.ManyToManyField(Tag, blank=True)
  </code></pre>
  
  <p>Any help is appreciated.</p>