From a66f7444cab3ace54e13e689d41cac8049e15d37 Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Fri, 16 Dec 2022 12:43:44 +0800 Subject: [PATCH 1/2] Allow select2_js to be list In certain cases such as breakage to select2 like the one below, one can have a patch by loading another js. https://github.com/select2/select2/issues/5993 --- django_select2/forms.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/django_select2/forms.py b/django_select2/forms.py index da7b5e0d..eaea7743 100644 --- a/django_select2/forms.py +++ b/django_select2/forms.py @@ -127,9 +127,11 @@ def media(self): .. Note:: For more information visit https://docs.djangoproject.com/en/stable/topics/forms/media/#media-as-a-dynamic-property """ - select2_js = [settings.SELECT2_JS] if settings.SELECT2_JS else [] + select2_js = settings.SELECT2_JS if settings.SELECT2_JS else [] select2_css = settings.SELECT2_CSS if settings.SELECT2_CSS else [] + if isinstance(select2_js, str): + select2_js = [select2_js] if isinstance(select2_css, str): select2_css = [select2_css] From 027c6f243133f4df2ec97afaebf4f5a8d4b1ea6b Mon Sep 17 00:00:00 2001 From: Johannes Maron Date: Wed, 8 Feb 2023 14:31:00 +0100 Subject: [PATCH 2/2] Chagne defaults to be lists --- django_select2/conf.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/django_select2/conf.py b/django_select2/conf.py index 0f34f774..a704eb17 100644 --- a/django_select2/conf.py +++ b/django_select2/conf.py @@ -55,32 +55,32 @@ class Select2Conf(AppConf): It has set `select2_` as a default value, which you can change if needed. """ - JS = "admin/js/vendor/select2/select2.full.min.js" + JS = ["admin/js/vendor/select2/select2.full.min.js"] """ The URI for the Select2 JS file. By default this points to version shipped with Django. If you want to select the version of the JS library used, or want to serve it from the local 'static' resources, add a line to your settings.py like so:: - SELECT2_JS = 'assets/js/select2.min.js' + SELECT2_JS = ['assets/js/select2.min.js'] If you provide your own JS and would not like Django-Select2 to load any, change this setting to a blank string like so:: - SELECT2_JS = '' + SELECT2_JS = [] .. tip:: Change this setting to a local asset in your development environment to develop without an Internet connection. """ - CSS = "admin/css/vendor/select2/select2.min.css" + CSS = ["admin/css/vendor/select2/select2.min.css"] """ The URI for the Select2 CSS file. By default this points to version shipped with Django. If you want to select the version of the library used, or want to serve it from the local 'static' resources, add a line to your settings.py like so:: - SELECT2_CSS = 'assets/css/select2.css' + SELECT2_CSS = ['assets/css/select2.css'] If you want to add more css (usually used in select2 themes), add a line in settings.py like this:: @@ -93,7 +93,7 @@ class Select2Conf(AppConf): If you provide your own CSS and would not like Django-Select2 to load any, change this setting to a blank string like so:: - SELECT2_CSS = '' + SELECT2_CSS = [] .. tip:: Change this setting to a local asset in your development environment to develop without an Internet connection.