user3806832
user3806832

Reputation: 703

why would I be getting Invalid block tag: 'static' error?

this is the head of of my 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>`

This part is the body, the statics files up above are loading correctly, I have some images in the body that I also want to load, they are located in the same folder but I have written the code in another file and used {% include "images.html" %} to add them to base.

ex. <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" />

Above is pretty much all of the code that is on the image html file, anyone know why I keep getting the Invalid block tag: 'static' error? The top of my base.html has the {% load staticfiles %} so does django require it on every file that has the static function, even if it is called as a text inclusion?

Upvotes: 2

Views: 1995

Answers (1)

catavaran
catavaran

Reputation: 45595

Yes, you should {% load staticfiles %} in every template which uses the {% static %} tag.

Excerpt from the documentation for the {% include %} tag:

The include tag should be considered as an implementation of “render this subtemplate and include the HTML”, not as “parse this subtemplate and include its contents as if it were part of the parent”. This means that there is no shared state between included templates – each include is a completely independent rendering process.

Upvotes: 5

Related Questions