Django模板图像不加载 [英] Django template image wan't load

查看:117
本文介绍了Django模板图像不加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

图片无法加载。我看到o破碎的图标。我使用静态标签。我也尝试给绝对路径,从来没有工作。我使用alt标签,但仍然只能看到破碎的图像图标。

  {%load static%} {#loads static tag#} 




< div id =header>
{%block header%}
< img src ={%staticimages / logo.png%} alt =替代文字/>
{%endblock%}
< / div>


解决方案

  {%load static%} {#loads static tag#} 
pre>

到此:

  {%load static from staticfiles% } 


Image wan't load.I see o broken image icon.I use the static tag. I also tried giving the absolute path and never worked.I used the alt tag but still i can only see the broken image icon. Is the tag correct what else should i try.The images is in static\images\logo.png

{% load static %} {# loads static tag #}

.
.

 <div id="header">
   {% block header %}
     <img src="{% static "images/logo.png" %} alt="alternative text"  />
   {% endblock %}
</div>

解决方案

Change:

{% load static %} {# loads static tag #}

to this:

{% load static from staticfiles %}

这篇关于Django模板图像不加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆