From ff2eecb1b437518145ded1bd89785b904ec8db3a Mon Sep 17 00:00:00 2001 From: Gianni Moschini Date: Sun, 12 Aug 2018 12:41:46 +0100 Subject: [PATCH 1/2] Only use django jQuery --- smart_selects/static/smart-selects/admin/js/bindfields.js | 2 +- smart_selects/static/smart-selects/admin/js/chainedfk.js | 2 +- smart_selects/static/smart-selects/admin/js/chainedm2m.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/smart_selects/static/smart-selects/admin/js/bindfields.js b/smart_selects/static/smart-selects/admin/js/bindfields.js index 295d563..3ec04fe 100755 --- a/smart_selects/static/smart-selects/admin/js/bindfields.js +++ b/smart_selects/static/smart-selects/admin/js/bindfields.js @@ -87,4 +87,4 @@ } }); }); -}(jQuery || django.jQuery)); +}(django.jQuery)); diff --git a/smart_selects/static/smart-selects/admin/js/chainedfk.js b/smart_selects/static/smart-selects/admin/js/chainedfk.js index 2c3b8dc..fb1d468 100755 --- a/smart_selects/static/smart-selects/admin/js/chainedfk.js +++ b/smart_selects/static/smart-selects/admin/js/chainedfk.js @@ -110,4 +110,4 @@ } }; }(); -}(jQuery || django.jQuery)); +}(django.jQuery)); diff --git a/smart_selects/static/smart-selects/admin/js/chainedm2m.js b/smart_selects/static/smart-selects/admin/js/chainedm2m.js index 86b2ee8..da32c00 100755 --- a/smart_selects/static/smart-selects/admin/js/chainedm2m.js +++ b/smart_selects/static/smart-selects/admin/js/chainedm2m.js @@ -177,4 +177,4 @@ } }; }(); -}(jQuery || django.jQuery)); +}(django.jQuery)); From fd7536c39997d0a4200167ad4cec7e0855a0c49c Mon Sep 17 00:00:00 2001 From: Gianni Moschini Date: Tue, 28 Apr 2020 18:21:17 +0100 Subject: [PATCH 2/2] Remove jQuery settings --- docs/index.rst | 1 - docs/installation.md | 2 -- docs/settings.md | 10 ---------- smart_selects/widgets.py | 23 ++++++++--------------- 4 files changed, 8 insertions(+), 28 deletions(-) delete mode 100644 docs/settings.md diff --git a/docs/index.rst b/docs/index.rst index a6c8250..1d04b1a 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -11,7 +11,6 @@ Contents :numbered: 1 installation - settings usage diff --git a/docs/installation.md b/docs/installation.md index 83a1c1e..8ea706a 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -15,5 +15,3 @@ url(r'^chaining/', include('smart_selects.urls')), ) ``` - -4. You will also need to include jQuery in every page that includes a field from `smart_selects`, or set `JQUERY_URL = True` in your project's `settings.py`. diff --git a/docs/settings.md b/docs/settings.md deleted file mode 100644 index f0b3a97..0000000 --- a/docs/settings.md +++ /dev/null @@ -1,10 +0,0 @@ -## Settings - -`JQUERY_URL` -: jQuery 2.2.0 is loaded from Google's CDN if this is set to `True`. If you would prefer to - use a different version put the full URL here. Set `JQUERY_URL = False` - to disable loading jQuery altogether. - -`USE_DJANGO_JQUERY` -: By default, `smart_selects` loads jQuery from Google's CDN. However, it can use jQuery from Django's - admin area. Set `USE_DJANGO_JQUERY = True` to enable this behaviour. diff --git a/smart_selects/widgets.py b/smart_selects/widgets.py index d0c06af..475edb6 100644 --- a/smart_selects/widgets.py +++ b/smart_selects/widgets.py @@ -18,9 +18,6 @@ get_model = apps.get_model -USE_DJANGO_JQUERY = getattr(settings, 'USE_DJANGO_JQUERY', False) -JQUERY_URL = getattr(settings, 'JQUERY_URL', 'https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js') - URL_PREFIX = getattr(settings, "SMART_SELECTS_URL_PREFIX", "") @@ -32,21 +29,17 @@ def media(self): js = [] - if JQUERY_URL: - js.append(JQUERY_URL) - elif JQUERY_URL is not False: - vendor = '' if django.VERSION < (1, 9, 0) else 'vendor/jquery/' - extra = '' if settings.DEBUG else '.min' + vendor = '' if django.VERSION < (1, 9, 0) else 'vendor/jquery/' + extra = '' if settings.DEBUG else '.min' - jquery_paths = [ - '{}jquery{}.js'.format(vendor, extra), - 'jquery.init.js', - ] + jquery_paths = [ + '{}jquery{}.js'.format(vendor, extra), + 'jquery.init.js', + ] - if USE_DJANGO_JQUERY: - jquery_paths = ['admin/js/{}'.format(path) for path in jquery_paths] + jquery_paths = ['admin/js/{}'.format(path) for path in jquery_paths] - js.extend(jquery_paths) + js.extend(jquery_paths) media += Media(js=js) return media