【发布时间】:2017-11-24 02:53:47
【问题描述】:
我使用 nginx 部署了我的 Django 应用程序并且工作正常。但是我的图像没有加载到页面中。静态文件夹不是问题,因为成功加载了 favicon 和 css 和 js 文件。
我查看了在 webbrowser 中形成的源代码,我看到图像在链接末尾有一个“/”。这使地址无效。如果手动删除“/”,我在站点中找到了资源。但我不知道是什么导致了这个字符的插入。
我的网站可用文件
server {
listen 80;
server_name localhost;
location = /favicon.ico {access_log_off; log_not_found off;}
location /static/ {
root /home/pi/WebSite;
}
location / {
include proxy_params;
proxy_pass http://unix:home/pi/WebSite/Website.sock;
}
}
我的设置.py
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR,'static/')
我的模板文件:
<div class='col-md-12 col-xs-12'>
<img class="img-rounded img-responsive text-center" src = {% static 'img/sistema.png' %}/>
<img class="img-rounded img-responsive text-center" src = {% static 'img/legenda.png' %}/>
</div>
在网站的源代码中,图片出现:
<div class='col-md-12 col-xs-12'>
<img class="img-rounded img-responsive text-center" src = /static/img/sistema.png/>
<img class="img-rounded img-responsive text-center" src = /static/img/legenda.png/>
</div>
有什么想法、建议吗? 非常感谢,我没有更多的想法
【问题讨论】:
-
我的错......我在错误的模式下使用了 img html 语句。 img 没有以“/>”结尾。抱歉,在开发模式下,页面工作正常 rsrs。
标签: django nginx static web-deployment gunicorn