【发布时间】:2015-05-24 13:26:53
【问题描述】:
这是我的base.html的头:
{% load staticfiles %}
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- the CSS for Foundation - Base of client side -->
<link rel="stylesheet" href="{% static 'css/foundation.css' %}" />
<!-- the CSS for Smooth Div Scroll -->
<link rel="Stylesheet" type="text/cs' %}" href="{% static 'top_scroll/css/smoothDivScroll.css' %}" />
<!-- the CSS for Custom -->
<link rel="stylesheet" href="{% static 'css/custom.css' %} />
<script src="{% static 'js/vendor/modernizr.js' %}"></script>
</head>`
这部分是正文,上面的静态文件加载正确,我在正文中有一些我也想加载的图像,它们位于同一个文件夹中,但我已将代码写入另一个文件并使用{% include "images.html" %} 将它们添加到基础。
例如。
<img src="{% static 'top_scroll/images/demo/field.jpg' %}" alt="Demo image" id="field" />
<img src="{% static 'top_scroll/images/demo/gnome.jpg' %}" alt="Demo image" id="gnome" />
<img src="{% static 'top_scroll/images/demo/pencils.jpg' %}" alt="Demo image" id="pencils" />
<img src="{% static 'top_scroll/images/demo/golf.jpg' %}" alt="Demo image" id="golf" />
上面几乎是图像 html 文件中的所有代码,有人知道为什么我不断收到 Invalid block tag: 'static' 错误吗?我的 base.html 的顶部有 {% load staticfiles %} 所以 django 是否在每个具有静态函数的文件上都需要它,即使它被称为文本包含?
【问题讨论】:
标签: python django django-templates