title: Displaying uploaded images in the template - Django
body: <p>I am trying to display uploaded images to a template for my imaginary vegetable catalogue.</p>
  
  <p>I have a page to <a href="https://stackoverflow.com/questions/32889199/how-to-upload-multiple-images-using-modelformset-django">add a new vegetable and upload images</a>. The main template is a list of vegetables which will later have thumbnails.</p>
  
  <p>Now, when viewing the detail page of the vegetable I want to display its images, but  the template is only displaying the string 'VegetableImage Object' in place of an image, even with img tags. </p>
  
  <p>I am confused because the template has obviously found the images but they are displayed just as a generic string.</p>
  
  <p>models.py</p>
  
  <pre><code>class Vegetable(models.Model):
          title = models.CharField(max_length=0)
          category = models.CharField(max_length=50,
                                      choices=CATEGORY_CHOICES)
          thumbnail = models.ImageField(upload_to = 'uploaded_images/')
  
  
  class VegetableImage(models.Model):
      vegetable = models.ForeignKey(Vegetable, default=None, related_name='images')
      image = models.ImageField(upload_to='images/vegetable',
                               verbose_name='image',)
  </code></pre>
  
  <p>view for main template (a list of all vegetables) and detail view</p>
  
  <pre><code>class VegetableView(generic.ListView):
      template_name = 'vegetable/vegetable.html'
      context_object_name = 'vegetable_list'
  
      def get_queryset(self):
          return Vegetable.objects.all()
  
  class DetailView(generic.DetailView):
      model = Vegetable
      template_name = 'vegetable/detail.html'
  </code></pre>
  
  <p>Detail template for displaying detail of vegetable</p>
  
  <pre><code>{% if view %}
      &lt;h1&gt;Title: {{ vegetable.title }}&lt;/h1&gt;
      &lt;h2&gt;Category: {{ vegetable.category }}&lt;/h2&gt;
      &lt;p&gt;Thumbnail: {{ vegetable.thumbnail }}&lt;/p&gt;
      &lt;p&gt;Images:     
  {% for vegetable in vegetable.images.all %}
      {{ vegetable }}
      {% endfor %}
  &lt;/p&gt;
  
  
  {% else %}
      &lt;p&gt; no vegetables found - error &lt;/p&gt;
  {% endif %}
  </code></pre>