我想通过在Django模板文件“index.html”中使用img src标记来显示图像:
templates/
index.html
static/
img/
puzzle.png
将图像添加到静态后我收集静态并在页面顶部我包括:
{% load static %}
我的图片标签是:
<img src="{% static 'img/puzzle.png' %}">
但图像没有显示在我的页面上。我怎样才能解决这个问题?
更改目录结构如下,
yourapp/
├── templates/
│ └── index.html
└── static/
└── yourapp
└── puzzle.png
然后在模板中
{% load static %}
<img src="{% static 'yourapp/puzzle.png' %}">