From 97b98a80cdc0cb99a2550550aa4766eeae6e2674 Mon Sep 17 00:00:00 2001 From: Gianni Moschini Date: Tue, 28 Apr 2020 18:21:17 +0100 Subject: [PATCH] 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 3e9d2fd..f34ec5f 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -9,5 +9,3 @@ url(r'^chaining/', include('smart_selects.urls')), ) ``` - -3. 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