Invalid block tag: 'static'

Server returned TemplateSyntaxError at / Invalid block tag: 'static' on this line: <img src="{% static 'icon/logo.png' %}">.

The whold html file is like this (it's an html file {% include %}ed by another one):

{% load staticfiles %}
<div class="header">
      <ul class="nav nav-pills pull-right">
        <li role="presentation"><a href="{% url 'offer rank' %}">潮品榜</a></li>
        <li role="presentation"><a href="{% url 'user rank' %}">达人榜</a></li>
        <li role="presentation"><a href="#" data-toggle="modal" data-target="#start">登陆</a></li>
        <li role="presentation"><a href="#" data-toggle="modal" data-target="#start">注册</a></li>
        {% if debug_users %}
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">切换用户<span class="caret"></span></a>
          <ul class="dropdown-menu" role="menu">
            {% for debug_user in debug_users %}
            <li><a href="{% url 'debug login' %}">{% if debug_user.kbjuser.user_type == '1' %}达人{% else %}商家{% endif %}: {{ debug_user.username }}</a></li>
            {% endfor %}
        {% endif %}
     <h3><img src="{% static 'icon/logo.png' %}">
        <a href="{% url 'home' %}" class="text-muted">口碑街</a>

And is like this:

# Static files (CSS, JavaScript, Images)

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, "static/")

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, "media/")

from hw.settings import *
from useraccess.settings import *

    # other finders..


I can't figure out what happens here.

Here are some more lines in

# Application definition





ROOT_URLCONF = 'ddw.urls'

WSGI_APPLICATION = 'ddw.wsgi.application'

LOGIN_URL = '/login/'


Make sure that 'django.contrib.staticfiles' is included in your INSTALLED_APPS.

this is number one in this checklist

This worked for me

{% load staticfiles %}

include {% load static %} just above section in html file, that will help your HTML file to load your css or js files

add {% load static %} at the top of html file, under the DOCTYPE html line

{% load static %} or {% load staticfiles %}

both will work. Just be sure you use equal amount of spaces between opening and closing of '{' and '%'.

It's OK now. I resolved it myself. I'm sorry. I confused two similar html files. The one I put on here (header.html) was right but header_authenticated.html was wrong.

Need Your Help

HTML text not rendered in proper way from JSON in MOBILE ANGULAR UI

javascript html angularjs json mobile-angular-ui

I am using MOBILE ANGULAR UI frame work. When i retrieved the Text(include tags) from JSON then text show with tags in .html file. I have seen one link but i did not get solution. This link is Angu...

How to include view/partial specific styling in AngularJS

css model-view-controller angularjs

What is the proper/accepted way to use separate stylesheets for the various views my application uses?