django 静态页面上没有静态文件

No static files on static page in django

我在 django 中有一个静态网站:domain.com/press/。此地址的页面可见,但静态文件存在问题 - 它们不显示。

控制台错误 (F12):

domain.com/press/%7B%%20static%20'images/presslogo.png'%20%%7D Failed to load resource: the server responded with a status of 400 (Bad Request)

我在 nginx 中的设置:

location /press/ {
    alias /path_to_templates/;
    index press.html;
}

我的部分 html 代码:

{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Press</title>
</head>
<body>
<img src="{% static 'images/presslogo.png' %}">
</body>
</html>

setting.py

STATIC_ROOT = os.path.join(BASE_DIR, 'static')

如何在静态页面上显示图片?

/press/ 由 nginx 提供服务。因此 <img src="{% static 'images/presslogo.png' %}"> 将不起作用。

请给出图片的准确路径。即


<img src="domain.com/<your-static-url>/images/presslogo.png">