1
0
mirror of https://github.com/django/django.git synced 2024-12-23 17:46:27 +00:00

Fixed #8058 -- Moved media for filter_vertical/filter_horizontal widget 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
This commit is contained in:
Brian Rosner 2008-08-31 17:20:43 +00:00
parent e1ea7014ad
commit d05ebdb649
2 changed files with 11 additions and 4 deletions

View File

@ -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)

View File

@ -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())