Django 图像标签不显示照片

Django image tag not displaying photo

我想在 Django 模板文件中使用 img src 标签显示图像 "index.html":

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' %}">


参考
Configuring static files