Opened 7 years ago

Closed 7 years ago

Last modified 5 years ago

#12778 closed (fixed)

InlineAdmin ignores inner Media class

Reported by: Florian Apolloner Owned by: nobody
Component: contrib.admin Version: master
Severity: Keywords:
Cc: Florian Apolloner Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

InlineAdmin ignores the Media class cause it inherits BaseModelAdmin. ModelAdmin has MediaDefiningClass as metaclass: http://code.djangoproject.com/browser/django/trunk/django/contrib/admin/options.py#L187 Imo it should get moved to BaseModelAdmin…

Attachments (1)

django-bug-12778.diff (4.1 KB) - added by Paul McLanahan 7 years ago.
Proposed fix and tests

Download all attachments as: .zip

Change History (12)

comment:1 Changed 7 years ago by Alex Gaynor

Triage Stage: UnreviewedAccepted

comment:2 Changed 7 years ago by Tobias McNulty

Owner: changed from nobody to Tobias McNulty
Status: newassigned

comment:3 Changed 7 years ago by Tobias McNulty

Owner: changed from Tobias McNulty to nobody
Status: assignednew

comment:4 Changed 7 years ago by Gonzalo Delgado

I'm surely missing something, but I don't see a need for having a Media class in an InlineAdmin class since an instance's forms will be rendered in the same page of the AdminForm instance that contains it, and any media (CSS, Javascript) you want in that page should be included in your AdminForm class definition.

comment:5 Changed 7 years ago by Florian Apolloner

Might be, but then it should get documented. On the other hand it's nice to not override the form just to add a js/css file…

comment:6 Changed 7 years ago by Gonzalo Delgado

I see your point. I don't find overriding forms to add media annoying though (perhaps I don't do it quite often).

Maybe this should be discussed in django-developers?

comment:7 Changed 7 years ago by Paul McLanahan

Owner: changed from nobody to Paul McLanahan
Status: newassigned

Changed 7 years ago by Paul McLanahan

Attachment: django-bug-12778.diff added

Proposed fix and tests

comment:8 Changed 7 years ago by Paul McLanahan

Has patch: set
Owner: changed from Paul McLanahan to nobody
Status: assignednew

Added tests to check for the addition of admin media from combinations of ModelAdmin and InlineModelAdmin.
Moved assignment of forms.MediaDefiningClass metaclass to BaseModelAdmin.

comment:9 Changed 7 years ago by Jannis Leidel

Resolution: fixed
Status: newclosed

(In [12825]) Fixed #12778 - Added media handling abilities to admin inlines. Thanks for the patch, pmclanahan.

comment:10 Changed 7 years ago by Jannis Leidel

(In [12864]) [1.1.X] Fixed #12778 - Added media handling abilities to admin inlines. Thanks for the patch, pmclanahan.

Backport from trunk, r12825.

comment:11 Changed 5 years ago by Jacob

milestone: 1.2

Milestone 1.2 deleted

Note: See TracTickets for help on using tickets.
Back to Top