2

I would like to load a specific javascript file for the specific html file. Instead of loading them into the base.html. Then a lot of pages will have unnecessary scripts that are not used.

I get this error:

Invalid block tag on line 3: 'static', expected 'endblock'. Did you forget to register or load this tag?

when i try to load it into the child.html. I'm

{% extends 'base.html' %}
{% block js %}
    <script src="{% static "javascript/week.js" %}" type="text/javascript"></script>
{% endblock %}

1 Answer 1

2

You need to do {% load static %} in any template file that uses the {% static %} tag.

Sign up to request clarification or add additional context in comments.

3 Comments

Something i cannot inherit from the base.html?
It doesn't matter if you inherit, you still need to explicitly load every template.
Thanks for the hrlp and explanation

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.