2

I have javascript that is running on a django app. I get a list from my views.py and after that I want to get the img url

The first line of code gets it and console log shows exactly what I want pictures/logo.png

The problem is that in the third line of code the variable img shows me this: %22%2bimg%2b%22

Can you see what I'm missing?

img = data[i].fields.imagen.substring(13);
console.log(img);

html += "<div class='brick "+size+"' style='background-image: url(\"{% static '"+img+"' %}\")'><div class='cover'>"+nombre+"</div></div>"
mplungjan
  • 169,008
  • 28
  • 173
  • 236
Jose Ramon
  • 65
  • 1
  • 10

1 Answers1

3

Solved it, i didn't have to write the

{% static '"+img+"' %} 

part like that, messed up some stuff, just had to put it like this

 url(\"/static/"+img+"\")
Jose Ramon
  • 65
  • 1
  • 10