Which is the best solution to pass {{ STATIC_URL }} to javascript files?
I’m working with django and python.
Thanks in advance.
Regards.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
django-compressorlets 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.https://github.com/jezdez/django_compressor
Enable the
TemplateFilterin settings.py after installing to parse your js or css files via the template engine.Now any JS within
{% compress js %}blocks will be parsed by the django template language…You asked for the best way — I think this is the best. Certainly better than serving dynamic files.