Permalink
Browse files

Fixed #8058 -- Moved media for filter_vertical/filter_horizontal widg…

…et to the widget for use outside the admin. This also corrects RelatedFieldWidgetWrapper to expose the media of the wrapped widget. Thanks Erwin for the report and cgrady and ramikassab for the complete patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@8764 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent e1ea701 commit d05ebdb6491669faaf21d91633974d385129a951 @brosner brosner committed Aug 31, 2008
Showing with 11 additions and 4 deletions.
  1. +0 −2 django/contrib/admin/options.py
  2. +11 −2 django/contrib/admin/widgets.py
@@ -203,8 +203,6 @@ def _media(self):
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)
@@ -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 @@ def __deepcopy__(self, memo):
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())

0 comments on commit d05ebdb

Please sign in to comment.