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
This commit is contained in:
Brian Rosner 2008-07-23 03:25:41 +00:00
parent 437945146d
commit 62d9e278d7
1 changed files with 8 additions and 2 deletions

View File

@ -556,14 +556,13 @@ class ModelAdmin(BaseModelAdmin):
adminForm = AdminForm(form, self.get_fieldsets(request, obj), self.prepopulated_fields) adminForm = AdminForm(form, self.get_fieldsets(request, obj), self.prepopulated_fields)
media = self.media + adminForm.media media = self.media + adminForm.media
for fs in inline_formsets:
media = media + fs.media
inline_admin_formsets = [] inline_admin_formsets = []
for inline, formset in zip(self.inline_instances, inline_formsets): for inline, formset in zip(self.inline_instances, inline_formsets):
fieldsets = list(inline.get_fieldsets(request, obj)) fieldsets = list(inline.get_fieldsets(request, obj))
inline_admin_formset = InlineAdminFormSet(inline, formset, fieldsets) inline_admin_formset = InlineAdminFormSet(inline, formset, fieldsets)
inline_admin_formsets.append(inline_admin_formset) inline_admin_formsets.append(inline_admin_formset)
media = media + inline_admin_formset.media
context = { context = {
'title': _('Change %s') % opts.verbose_name, 'title': _('Change %s') % opts.verbose_name,
@ -759,6 +758,13 @@ class InlineAdminFormSet(object):
def fields(self): def fields(self):
for field_name in flatten_fieldsets(self.fieldsets): for field_name in flatten_fieldsets(self.fieldsets):
yield self.formset.form.base_fields[field_name] 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): class InlineAdminForm(AdminForm):
""" """