0

I'm passing an array of files using this method

How to pass an array in Django to a template and use it with JavaScript

all is well if I have the script within the .html but if I want to have a separate example.js file, the only current way to get it working is to create the var in the html and then call it from example.js.

In an effort to keep things tidy and in one place, I'd like to avoid doing this. Is it possible to put it into the example.js ?

noName
  • 13
  • 1
  • No, because the Django logic won't be interpreted within a JS file. The usual pattern to follow in these cases is to put the required Django output in the main HTML (either in `data` attributes or defined in JS variables contained in plain ` – Rory McCrossan Sep 20 '18 at 09:27
  • Thanks Rory, this is the confirmation I required – noName Sep 20 '18 at 14:53

0 Answers0