Search code examples
djangostaticblock

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


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'


Solution

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