Reputation: 2244
I was wondering if I could use the template tag static in my javascript file to call a CSV file I want to pass to D3 like so:
{% static "js/data.csv" %}
I'd really like my JavaScript files to be separate from my HTML, because it can get long and messy. Thanks for any help.
Upvotes: 1
Views: 2054
Reputation: 2569
django-compressor lets you do this as well as optimize your site by condensing all of your required JS or CSS into one file and optimizing file size.
UPDATE: By default, compressor will convert relative urls into absolute urls using STATIC_URL. If you download the development version, it comes with a django template engine parser which lets you use all django template code directly in your CSS files, such as the {% static %} tag.
by Yuji 'Tomita' Tomita
Read this SO Post.
Upvotes: 1