I am attempting to add a custom Javascript variable to my Django static url. Unfortunately, the below code is failing.
$(document).ready(function() {
var randomNum = Math.floor((Math.random() * 12) + 1)
var text = "{% static '5LW/images/slider/" + randomNum + ".1.jpg' %}"
document.getElementById("headerImage").style.backgroundImage = url(text)
});
I receive the error:
--
**Error during template rendering**
Could not parse the remainder: ''5LW/images/slider/"' from ''5LW/images/slider/"'
var text = "{% static '5LW/images/slider/" + randomNum + ".1.jpg %}"
--
How would I go about fixing this?