fix possible upgrading exception: js in Media might be a tuple
@@ -6,7 +6,7 @@ from django.core.exceptions import ObjectDoesNotExist
from django.contrib.admin.sites import site as admin_site
from django.apps import apps
from django.db.models.fields.related import ManyToOneRel
-from django.forms import fields, ModelChoiceField
+from django.forms import fields, Media, ModelChoiceField
from django.forms.models import ModelForm
from django.forms.widgets import Select as SelectWidget
from django.utils.html import format_html
@@ -36,8 +36,9 @@ if 'django_select2' in settings.INSTALLED_APPS:
def media(self):
parent_media = super(HeavySelectWidget, self).media
# prepend JS snippet to re-add 'jQuery' to the global namespace
- parent_media._js.insert(0, 'cascade/js/admin/jquery.restore.js')
- return parent_media
+ js = ['cascade/js/admin/jquery.restore.js']
+ js.extend(parent_media._js)
+ return Media(css=parent_media._css, js=js)
def render(self, name, value, attrs=None):
try:
