django模板中的图像(images in django templates)
我解析图像并显示它。 按照我的意愿,我解析了。 正在解析新闻提要。 在模板中,我想检查条件,如果可用图像意味着它将显示图像,否则它应该在静态文件夹中显示图像。 我需要检查一下我的语法。
模板文件:
{% for i in arr %} <img src="{% if image %}{{i.image}}{% else %}{<img src="/static/img/image.jpeg">}{% endif %}" style="width:100px;height:100px;"> {% endfor %}以上是我编写的代码,但不显示图像。 请指导我继续
Am parsing images and displaying it. As my wish I parsed. Am parsing news feed. In templates I want to check the condition that if images available means it will show the images otherwise it should show the image in static folder. I need to check my syntax.
Template file:
{% for i in arr %} <img src="{% if image %}{{i.image}}{% else %}{<img src="/static/img/image.jpeg">}{% endif %}" style="width:100px;height:100px;"> {% endfor %}The above is the code that I have written but the images are not displayed. Please guide me to proceed further
最满意答案
请检查以下必须解决问题的代码:
{% for i in arr %} <img src="{% if i.image %}{{ i.image.url }}{% else %}{{ STATIC IMAGE URL }}{% endif %}" style="width:100px;height:100px;"> {% endfor %}Please check the following code that must solve your problem:
{% for i in arr %} <img src="{% if i.image %}{{ i.image.url }}{% else %}{{ STATIC IMAGE URL }}{% endif %}" style="width:100px;height:100px;"> {% endfor %}更多推荐
发布评论