在django的几个页面中,没有从base.html显示图像
我有一个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
{% 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>© 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>