diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py index 4643e3590b5..62e4aaedc3c 100644 --- a/django/contrib/admin/options.py +++ b/django/contrib/admin/options.py @@ -203,8 +203,6 @@ class ModelAdmin(BaseModelAdmin): js.append('js/urlify.js') if self.opts.get_ordered_objects(): js.extend(['js/getElementsBySelector.js', 'js/dom-drag.js' , 'js/admin/ordering.js']) - if self.filter_vertical or self.filter_horizontal: - js.extend(['js/SelectBox.js' , 'js/SelectFilter2.js']) return forms.Media(js=['%s%s' % (settings.ADMIN_MEDIA_PREFIX, url) for url in js]) media = property(_media) diff --git a/django/contrib/admin/widgets.py b/django/contrib/admin/widgets.py index d3deada0ede..15720a792b6 100644 --- a/django/contrib/admin/widgets.py +++ b/django/contrib/admin/widgets.py @@ -17,9 +17,14 @@ class FilteredSelectMultiple(forms.SelectMultiple): """ A SelectMultiple with a JavaScript filter interface. - Note that the resulting JavaScript assumes that the SelectFilter2.js - library and its dependencies have been loaded in the HTML page. + Note that the resulting JavaScript assumes that the jsi18n + catalog has been loaded in the page """ + class Media: + js = (settings.ADMIN_MEDIA_PREFIX + "js/core.js", + settings.ADMIN_MEDIA_PREFIX + "js/SelectBox.js", + settings.ADMIN_MEDIA_PREFIX + "js/SelectFilter2.js") + def __init__(self, verbose_name, is_stacked, attrs=None, choices=()): self.verbose_name = verbose_name self.is_stacked = is_stacked @@ -182,6 +187,10 @@ class RelatedFieldWidgetWrapper(forms.Widget): memo[id(self)] = obj return obj + def _media(self): + return self.widget.media + media = property(_media) + def render(self, name, value, *args, **kwargs): rel_to = self.rel.to related_url = '../../../%s/%s/' % (rel_to._meta.app_label, rel_to._meta.object_name.lower())