From 62d9e278d7230f035b3521492c28dd8c1f66147a Mon Sep 17 00:00:00 2001 From: Brian Rosner Date: Wed, 23 Jul 2008 03:25:41 +0000 Subject: [PATCH] Fixed #7898 -- Moved formset media definition to a media property in InlineAdminFormSet display helper and added InlineAdminForm media at the same time. This now properly renders all media associated with the formset and its display helper children. Thanks dima.kozlov for the report. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8057 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/admin/options.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py index c6bfbee924..1df399bd5a 100644 --- a/django/contrib/admin/options.py +++ b/django/contrib/admin/options.py @@ -556,14 +556,13 @@ class ModelAdmin(BaseModelAdmin): adminForm = AdminForm(form, self.get_fieldsets(request, obj), self.prepopulated_fields) media = self.media + adminForm.media - for fs in inline_formsets: - media = media + fs.media inline_admin_formsets = [] for inline, formset in zip(self.inline_instances, inline_formsets): fieldsets = list(inline.get_fieldsets(request, obj)) inline_admin_formset = InlineAdminFormSet(inline, formset, fieldsets) inline_admin_formsets.append(inline_admin_formset) + media = media + inline_admin_formset.media context = { 'title': _('Change %s') % opts.verbose_name, @@ -759,6 +758,13 @@ class InlineAdminFormSet(object): def fields(self): for field_name in flatten_fieldsets(self.fieldsets): yield self.formset.form.base_fields[field_name] + + def _media(self): + media = self.formset.media + for fs in self: + media = media + fs.media + return media + media = property(_media) class InlineAdminForm(AdminForm): """