title: django template - displaying images in table
body: <p>I can't get images (or image links) to display on template.  Everything else is working on the template but the image "render_thumbnail", which is defined in a custom model method. What am I doing wrong?  -btw the render_thumbnail works on another template when I am working only with the Images table, and am displaying using  -   images.render_thumbnail.  Thanks.</p>
  
  <p>Models.py</p>
  
  <pre><code>class Listings(models.Model):
      createdate = models.DateTimeField(auto_now_add=True)
      expirydate = models.DateTimeField(null=True, blank=True)
      price = models.IntegerField(null=True, blank=True)
      broker_y_n = models.CharField(max_length=1, blank=True, choices=broker, default='n')
      listing_type = models.ForeignKey(ListingType)
      listing_status = models.ForeignKey(ListingStatus, default=3)
      customer = models.ForeignKey(Customer)
  
  class Image(models.Model):
      title = models.CharField(max_length=60, blank=True, null=True)
      image = models.ImageField(upload_to="images/", blank=True, null=True)
      thumbnail = models.ImageField(upload_to="images/", blank=True, null=True)
      thumbnail2 = models.ImageField(upload_to="images/", blank=True, null=True)
      #tags = models.ManyToManyField(Tag, blank=True)
      #albums = models.ManyToManyField(Album, blank=True)
      created = models.DateTimeField(auto_now_add=True)
      #rating = models.IntegerField(default=50)
      width = models.IntegerField(blank=True, null=True)
      height = models.IntegerField(blank=True, null=True)
      listings = models.ForeignKey(Listings)
      def save(self, *args, **kwargs):
          # Save image dimensions
          super(Image, self).save(*args, **kwargs)
          im = PImage.open(pjoin(MEDIA_ROOT, self.image.name))
          self.width, self.height = im.size
          # large thumbnail
          fn, ext = os.path.splitext(self.image.name)
          im.thumbnail((256,256), PImage.ANTIALIAS)
          thumb_fn = fn + "-thumb2" + ext
          tf2 = NamedTemporaryFile()
          im.save(tf2.name, "JPEG")
          self.thumbnail2.save(thumb_fn, File(open(tf2.name)), save=False)
          tf2.close()
          # small thumbnail
          im.thumbnail((60,60), PImage.ANTIALIAS)
          thumb_fn = fn + "-thumb" + ext
          tf = NamedTemporaryFile()
          im.save(tf.name, "JPEG")
          self.thumbnail.save(thumb_fn, File(open(tf.name)), save=False)
          tf.close()
          super(Image, self).save(*args, **kwargs)
      def size(self):
          # Image size #
          return "%s x %s" % (self.width, self.height)
      def render_thumbnail(self):
          return mark_safe("""&lt;a href = "/media/%s"&gt;&lt;img border="0" alt=""     src="/media/%s" /&gt;&lt;/a&gt;""" % ((self.image.name, self.thumbnail.name)))
      #render_thumbnail.allow_tags = True
      def render_thumbnail2(self):
          return mark_safe("""&lt;a href = "/media/%s"&gt;&lt;img border="0" alt="" src="/media/%s" /&gt;&lt;/a&gt;""" % ((self.image.name, self.thumbnail2.name)))
      #render_thumbnail.allow_tags = True
      def __unicode__(self):
      return self.image.name
  </code></pre>
  
  <p>View.py</p>
  
  <pre><code>def details_customer(request, user_id):
      customer = get_object_or_404(Customer, user=user_id)
      cusnum=customer.id
      image = Image.objects.all()    
      listings = Listings.objects.filter(customer=cusnum).values(
          'id',
          'price',
          'listing_type__desc',
          'listing_status',
          'listing_status__desc',
          'canoekayak__builder',
          'image__title',
          'image__thumbnail',
          'image__render_thumbnail',        
          )
      context = Context({
          'title': 'Details',
          'customer': customer,
          'image' : image,        
          'listings' : listings,
          })
      return render_to_response('bsmain/details.html', context)
  </code></pre>
  
  <p>Template table</p>
  
  <pre><code>&lt;TABLE id="some_id"&gt;    
  &lt;TBODY&gt;
      {% load humanize %}
      {% for row in listings %}
      &lt;tr&gt;
          &lt;td&gt;{{ row.id }}&lt;/td&gt;
          &lt;td align="right"&gt;{{row.price|intcomma}}&lt;/td&gt;
          &lt;td&gt;{{ row.listing_type__desc}}&lt;/td&gt;
          &lt;td&gt;{{ row.listing_status}}&lt;/td&gt;
          &lt;td&gt;{{ row.listing_status__desc}}&lt;/td&gt;
          &lt;td&gt;{{ row.canoekayak__builder}}&lt;/td&gt;
          &lt;td&gt;{{ row.image__title}}&lt;/td&gt;
          &lt;td&gt;{{ row.image__thumbnail}}&lt;/td
          &lt;td&gt;{{ row.image__render_thumbnail}}&lt;/td            
      &lt;/tr&gt;
      {% endfor %}
  &lt;/TBODY&gt;
  </code></pre>
  
  <p></p>