Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在django的几个页面中,没有从base.html显示图像_Html_Css_Django_Django Templates - Fatal编程技术网

在django的几个页面中,没有从base.html显示图像

在django的几个页面中,没有从base.html显示图像,html,css,django,django-templates,Html,Css,Django,Django Templates,我有一个base.html,我还扩展到了其他页面。在少数页面中显示图像,但在少数页面中不显示。除图像外,还会显示标题、节等所有内容 {% load staticfiles %} some more --like header , section <footer> <div id="footer"> {% block footer %} <a href="https://github.com/shanker4999"> <img

我有一个base.html,我还扩展到了其他页面。在少数页面中显示图像,但在少数页面中不显示。除图像外,还会显示标题、节等所有内容

{% load staticfiles %}
some more --like header , section 
<footer>
<div id="footer">
    {% block footer %}
        <a href="https://github.com/shanker4999"> <img src ="../../static/blog/images/git.png"></a>
        <p>&copy; 2016 shankar.</p>
    {% endblock %}
</div>

您正在加载
静态文件
,但您从未实际使用过它,您应该使用模板标记

"../../static/blog/images/git.png"
应该是

{% static 'blog/images/git.png' %}

您还应该使用url模板标记。

这是因为您没有使用正确的src。应该让静态函数处理静态文件。当url更改时,
。/../
将不再正确,具体取决于路径

您应该在settings.py文件中配置静态目录,然后像这样引用图像:

<img src ="{% static 'blog/images/git.png' %}"></a>

"../../static/blog/images/git.png"
{% static 'blog/images/git.png' %}
<img src ="{% static 'blog/images/git.png' %}"></a>