diff --git a/django_select2/forms.py b/django_select2/forms.py index 69b1ee3c..85f84672 100644 --- a/django_select2/forms.py +++ b/django_select2/forms.py @@ -169,8 +169,12 @@ class Select2AdminMixin: def media(self): css = {**AutocompleteMixin(None, None).media._css} css["screen"].append("django_select2/django_select2.css") + js = [*Select2Mixin().media._js] + js.insert( + js.index("django_select2/django_select2.js"), "admin/js/jquery.init.js" + ) return forms.Media( - js=Select2Mixin().media._js, + js=js, css=css, ) diff --git a/tests/test_forms.py b/tests/test_forms.py index ddb0f328..71b0b042 100644 --- a/tests/test_forms.py +++ b/tests/test_forms.py @@ -188,6 +188,7 @@ def test_media(self): assert tuple(Select2AdminMixin().media._js) == ( "admin/js/vendor/select2/select2.full.min.js", "admin/js/vendor/select2/i18n/en.js", + "admin/js/jquery.init.js", "django_select2/django_select2.js", )