Search code examples
pythondjangoimagefield

retrieving uploaded images with django's ImageField


this is the code in my models file:

from django.db import models

class Studio(models.Model):
    .....
    .....
    metroimage = models.ImageField(upload_to='images', blank=True)

this is the code on the template file:

 {% for place in studio %}
            .....
            .....
                    <img class="metro" src="{{ place.metroimage.url }}"><b>{{ place.metro }}</b><br>

                {% endif %}

but when the page displays i get this (this is source-code)

        .....
        .....     
                    <img class="metro" src="/http://momo.webfactional.com/media/images/m3.png"><b>Zara</b><br>

what's with the forward slash before http? i can't get the uploaded image to display...


Solution

  • I'd guess your MEDIA_URL settings (in settings.py) is to blame for the extra slash.