title: Accessing a ManyToManyField's contents for a Django template
body: <p>I'm making a low-spec e-bay clone, I'm trying to implement a watchlist function but the problem is I can't access the ManyToManyField in the Watchlist model so I can use the contents of the field in the template I'm using. To display each user's watchlist to them, so far I only get this result:
  <a href="https://i.stack.imgur.com/9c7TJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9c7TJ.png" alt="enter image description here" /></a> but I need to get a result like so:
  <a href="https://i.stack.imgur.com/HnPoa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HnPoa.png" alt="enter image description here" /></a></p>
  <p>Code I'm using:</p>
  <p><strong>watchlist.html</strong></p>
  <pre><code>{% extends &quot;auctions/layout.html&quot; %}
  
  {% load static %}
  
  {% block title %} {{name}}'s Watchlist {% endblock %}
  
  {% block body %}
  &lt;h2&gt;{{name}}'s Watchlist&lt;/h2&gt;
  
  {% for listing in watchlist %}
  &lt;div class='listing'&gt;
      &lt;h3&gt;{{ listing.list_title}}&lt;/h3&gt;
      {% if listing.img_url == &quot;&quot; %}
          &lt;a href='#'&gt;&lt;img src=&quot;{% static 'auctions/img404.png' %}&quot; class='img-fluid'&gt;&lt;/a&gt;
      {% else %}
          &lt;a href='#'&gt;&lt;img src=&quot;{{ listing.img_url }}&quot; class=&quot;img-fluid&quot; alt='image of {{ listing.list_title }}'&gt;&lt;/a&gt;
      {% endif %}
      &lt;p&gt;
          {{ listing.desc }}
      &lt;/p&gt;
      &lt;p&gt;
          Current Bid: ${{ listing.start_bid }}
      &lt;/p&gt;
      {% if listing.category == &quot;&quot; %}
          &lt;p&gt;Category: No Category Listed&lt;/p&gt;
      {% else %}
          &lt;p&gt;Category: {{ listing.category }}&lt;/p&gt;
      {% endif %}
      &lt;a href='#' class='btn btn-primary' id='go'&gt;Go To Listing&lt;/a&gt;
  &lt;/div&gt;
  {% endfor %}
  {% endblock %}
  </code></pre>
  <p><strong>views.py</strong></p>
  <pre><code>def render_listing(request, title):
      if request.method == &quot;POST&quot;:
          form = BidForm(request.POST)
          bid = int(request.POST['new_bid'])
          listing = Auction_Listing.objects.get(list_title=title)
          comments = Auction_Comments.objects.all().filter(auction_id=listing)
          if bid &lt; listing.start_bid:
              error = True
          else:
              error = False
              listing.start_bid = bid
              listing.save()
          return render(request, 'auctions/listing.html', {
              &quot;listing&quot;: listing,
              &quot;form&quot;: form,
              &quot;comments&quot;: comments,
              &quot;error&quot;: error
          })
      else:
          form = BidForm()
          listing = Auction_Listing.objects.get(list_title=title)
          comments = Auction_Comments.objects.all().filter(auction_id=listing)
          return render(request, 'auctions/listing.html', {
              &quot;listing&quot;: listing,
              &quot;form&quot;: form,
              &quot;comments&quot;: comments,
              &quot;error&quot;: False
          })
  
  @login_required
  def watchlist_render(request):
      user = request.user.id
      username = request.user.username
      watched = Watchlist.objects.filter(user_id=user)
      return render(request, 'auctions/watchlist.html', {
          &quot;watchlist&quot;: watched,
          &quot;name&quot;: username
      })
  </code></pre>
  <p><strong>models.py</strong></p>
  <pre><code>from django.contrib.auth.models import AbstractUser
  from django.db import models
  from django.db.models.deletion import CASCADE
  
  CATEGORIES = [
          ('Appliances', 'Appliances'),
           ('Tech', 'Tech'), 
           ('Gaming', 'Gaming'), 
           ('Fashion', 'Fashion'), 
           ('Sports and Fitness','Sports and Fitness'), 
           ('Other','Other'),
           (&quot;Hygiene and Medicine&quot;,&quot;Hygiene and Medicine&quot;), 
           (&quot;Stationery&quot;,&quot;Stationery&quot;),
          ('Decor', 'Decor'), 
          ('Furniture','Furniture'), 
          ('Cars and Mechanical Things','Cars and Mechanical Things'), 
          (&quot;Tools&quot;,&quot;Tools&quot;)
      ]
  
  # Create models here
  class User(AbstractUser):
      pass
  
  class Auction_Listing(models.Model):
      user_id = models.IntegerField(default=1)
      list_title = models.CharField(max_length=64)
      desc = models.TextField(max_length=324)
      img_url = models.URLField(max_length=200, null=True, blank=True)
      start_bid = models.IntegerField()
      category = models.CharField(choices=CATEGORIES, max_length=35, null=True, blank=True)
  
      def __str__(self):
          return f&quot;ID:{self.id}, {self.list_title}: {self.desc}, {self.start_bid} posted by user:{self.user_id} in Category:{self.category}, url:{self.img_url}&quot;
  
  class Bids(models.Model):
      bid = models.IntegerField(default=0)
      user_id = models.IntegerField(default=1)
      auction_id = models.ManyToManyField(Auction_Listing)
  
      def __str__(self):
          return f&quot;ID:{self.id}, Bid {self.bid} posted by user:{self.user_id} on auction {self.auction_id}&quot;
  
  class Auction_Comments(models.Model):
      user_id = models.IntegerField(default=1)
      comment = models.TextField(max_length=324, default='N/A')
      auction_id = models.ManyToManyField(Auction_Listing)
  
      def __str__(self):
          return f&quot;ID:{self.id}, Comment: {self.comment} posted by user:{self.user_id} on auction {self.auction_id}&quot;
  
  class Watchlist(models.Model):
      user_id = models.ForeignKey(User, on_delete=CASCADE,default=1)
      auction_id = models.ManyToManyField(Auction_Listing, related_name='auction_listing')
  
      def __str__(self):
          return f&quot;ID:{self.user_id} on auction {self.auction_id}&quot;
  
  </code></pre>
  <p>Thanks in advance for the help!</p>
  <p>Kind Regards
  <br>
  PrimeBeat</p>
  <p>EDIT: The results of the links as  @nigel222 requested
  <a href="https://i.stack.imgur.com/kjV7I.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kjV7I.png" alt="enter image description here" /></a></p>