Django : Is it impossible to static tag into block tag?

nextdoordoc picture nextdoordoc · Mar 26, 2014 · Viewed 38.6k times · Source

The code below makes error.. How could I resolve this problem?

{% block header %}
    <link rel="stylesheet" href="{% static 'shop/style.css' %}" />
{% endblock %}

The error output:

TemplateSyntaxError : Invalid block tag: 'static', expected 'endblock'

Answer

David C picture David C · Jul 12, 2014

No, it is not impossible. Try including {% load staticfiles%} in the same html file, rather than attempting to inherit it from some base.html.