Skip to content

Commit 38ce1d6

Browse files
pickfirecodingjoe
andauthored
Add list support for static asset settings (#189)
Co-authored-by: Johannes Maron <[email protected]>
1 parent 3e1527f commit 38ce1d6

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

django_select2/conf.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,32 +55,32 @@ class Select2Conf(AppConf):
5555
It has set `select2_` as a default value, which you can change if needed.
5656
"""
5757

58-
JS = "admin/js/vendor/select2/select2.full.min.js"
58+
JS = ["admin/js/vendor/select2/select2.full.min.js"]
5959
"""
6060
The URI for the Select2 JS file. By default this points to version shipped with Django.
6161
6262
If you want to select the version of the JS library used, or want to serve it from
6363
the local 'static' resources, add a line to your settings.py like so::
6464
65-
SELECT2_JS = 'assets/js/select2.min.js'
65+
SELECT2_JS = ['assets/js/select2.min.js']
6666
6767
If you provide your own JS and would not like Django-Select2 to load any, change
6868
this setting to a blank string like so::
6969
70-
SELECT2_JS = ''
70+
SELECT2_JS = []
7171
7272
.. tip:: Change this setting to a local asset in your development environment to
7373
develop without an Internet connection.
7474
"""
7575

76-
CSS = "admin/css/vendor/select2/select2.min.css"
76+
CSS = ["admin/css/vendor/select2/select2.min.css"]
7777
"""
7878
The URI for the Select2 CSS file. By default this points to version shipped with Django.
7979
8080
If you want to select the version of the library used, or want to serve it from
8181
the local 'static' resources, add a line to your settings.py like so::
8282
83-
SELECT2_CSS = 'assets/css/select2.css'
83+
SELECT2_CSS = ['assets/css/select2.css']
8484
8585
If you want to add more css (usually used in select2 themes), add a line
8686
in settings.py like this::
@@ -93,7 +93,7 @@ class Select2Conf(AppConf):
9393
If you provide your own CSS and would not like Django-Select2 to load any, change
9494
this setting to a blank string like so::
9595
96-
SELECT2_CSS = ''
96+
SELECT2_CSS = []
9797
9898
.. tip:: Change this setting to a local asset in your development environment to
9999
develop without an Internet connection.

django_select2/forms.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,11 @@ def media(self):
127127
.. Note:: For more information visit
128128
https://docs.djangoproject.com/en/stable/topics/forms/media/#media-as-a-dynamic-property
129129
"""
130-
select2_js = [settings.SELECT2_JS] if settings.SELECT2_JS else []
130+
select2_js = settings.SELECT2_JS if settings.SELECT2_JS else []
131131
select2_css = settings.SELECT2_CSS if settings.SELECT2_CSS else []
132132

133+
if isinstance(select2_js, str):
134+
select2_js = [select2_js]
133135
if isinstance(select2_css, str):
134136
select2_css = [select2_css]
135137

0 commit comments

Comments
 (0)