Closed GregUK closed 9 years ago
I think it would be ok to store underscore locally instead of loading from the CDN, if you or anyone sends a PR with this little modification I'll accept it.
The approach I was planning to use was to check the settings and set a default if it doesnt exist. such as:
from django.conf import settings
...
internal_js = [
getattr(settings, 'UNDERSCORE_JS_PATH', "//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js"
]
why complicating your life when django.contrib.static does a great job at handling static files?
How would you recommend approaching it?
The standard practice in django apps is to ship JS files inside the static/ dir, which then are collected automatically when one runs manage.py collectstatic.
if we want to retain the possibility to load from CDN we could add do something like:
if(getattr(settings, 'DJANGO_HSTORE_UNDERSCOREJS_CDN', False)):
underscorejs = "//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js
else:
underscorejs = "django_hstore/underscore-min.js"
I'll update accordingly
This was merged and released in 1.3.6, see #91 for more info
django_hstore/widgets.py
There is hardcoded external_js to cloudflare. Should be able to easily override to use internal CDN f required or other source.