如何通过Python / Django

时间:2015-10-02 19:15:18

标签: python django image-rendering

我在python中的List中存储了图像的URL。
我应该如何使用Django在我的网页上显示这些图像。

1 个答案:

答案 0 :(得分:1)

尝试:

# HTML file
# If your list is 'urls'
{% for url in urls %}
    <img src="{{ url }}" />
{% endfor %}

修改

根据您的评论,我收到了您的网址列表,您应该像这样保存您的列表:

['toi.cricbuzz.com/scripts/images/toi-logo.gif', 'toi.cricbuzz.com/scripts/images/cb-logo.png', 'img.cricketcb.com/i/gallery/fth/140x75/images/2015/oct/2/…', 'img.cricketcb.com/i/gallery/fth/140x75/images/2015/oct/1/…', 'img.cricketcb.com/i/gallery/fth/140x75/images/2015/sep/27/…', 'img.cricketcb.com/i/gallery/fth/140x75/images/2015/sep/17/…']

您可以在模板中测试上面的此列表,它应该显示图像。