开发者

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)

        .....
        ...开发者_JS百科..     
                    <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...


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜