In my script.js:
pic.src = "/static/photos/1.jpg"; // This works
pic2.src = "{% static 'photos/1.jpg' %}" // Does not work
Why in the world this happens? Since in my home.html, the {% static 'path' %} works:
{% load staticfiles %}
<script src="{% static 'script.js' %}"></script> // This works
And is it {% load staticfiles %} or {% load static %} ? Both work for me, script.js is loaded.
See Question&Answers more detail:os