在Django模板中,图像无法正确显示

时间:2020-01-24 14:11:11

标签: html django image templates

我有一个模型类,其中包含current_value和previous_value字段。 然后,在listview使用的模板中,在循环内部,我有这样的代码:

{% if data.current_value < data.previous_value %}
    <img src="{% static 'app1/negative.png' %}" width="40" height="40">
    <h1>Price down</h1>
{% elif data.current_value > data.previous_value %}
    <img src="{% static 'app1/positive.png' %}" width="40" height="40">
    <h1>Price up</h1>
{% else %}
    <img src="{% static 'app1/neutral.png' %}" width="40" height="40">
    <h1>Price the same</h1>
{% endif %}

H1文本正确显示,图像不正确。更具体-对于“其他”条件的图片,我认为总是可以的,但是对于“如果”和“其他”则显示相同的图片(其中之一)。

令人困惑和恼怒。我在做什么错了?

1 个答案:

答案 0 :(得分:0)

如果该模板的所有分支的h1文本正确显示,但是某些图像相同,则最可能的问题是图像文件是同一图像,但文件名不同。 / p>

相关问题