Opened 6 years ago

Closed 5 years ago

Last modified 4 years ago

#12778 closed (fixed)

InlineAdmin ignores inner Media class

Reported by: apollo13 Owned by: nobody
Component: contrib.admin Version: master
Severity: Keywords:
Cc: apollo13 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 pmclanahan 5 years ago.
Proposed fix and tests

Download all attachments as: .zip

Change History (12)

comment:1 Changed 6 years ago by Alex

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 6 years ago by tobias

  • Owner changed from nobody to tobias
  • Status changed from new to assigned

comment:3 Changed 6 years ago by tobias

  • Owner changed from tobias to nobody
  • Status changed from assigned to new

comment:4 Changed 5 years ago by gonzalodelgado

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 5 years ago by apollo13

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 5 years ago by gonzalodelgado

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 5 years ago by pmclanahan

  • Owner changed from nobody to pmclanahan
  • Status changed from new to assigned

Changed 5 years ago by pmclanahan

Proposed fix and tests

comment:8 Changed 5 years ago by pmclanahan

  • Has patch set
  • Owner changed from pmclanahan to nobody
  • Status changed from assigned to new

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 5 years ago by jezdez

  • Resolution set to fixed
  • Status changed from new to closed

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

comment:10 Changed 5 years ago by jezdez

(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 4 years ago by jacob

  • milestone 1.2 deleted

Milestone 1.2 deleted

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