Opened 3 days ago
Closed 17 hours ago
#36538 closed New feature (wontfix)
Addition of `AdminSite.media` for adding JS and CSS files globally to every admin page
Reported by: | Michał Pokusa | Owned by: | |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | Normal | Keywords: | admin adminsite media script style global |
Cc: | Michał Pokusa | Triage Stage: | Unreviewed |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I propose adding the property media
to AdminSite
class, with similar functionality as ModelAdmin.media
. The main reason for it is making it easy to add any JS/CSS globally for every admin page, and it will make the media management more consistent across the admin.
While it is possible to do that now by extending one of the base templates and manually adding the script or link tag, the main benefit will be the ability to separate this from the templates completely and in future, maybe moving all hard-coded media html tags to AdminSite.media
thus making the template cleaner and making it possible to take advantage of Media
merging logic.
Instalation of packages that add custom styles or scripts would be simplified, and be as easy as inheriting from a admin site mixin:
class CustomAdminSite(PackageMixin, AdminSite) ...
Implementation would require adding the AdminSite.media
property and small modification to the admin/base.html
template.
If this issue is accepted, I would be happy to take on it.
Thank you for your suggestion! When suggesting a new feature for Django, the feature idea should first be proposed and discussed with the community. To do that, please raise this on the new feature tracker.
I'll close the ticket for now, but if the community agrees with the proposal, please return to this ticket and reference the forum discussion so we can re-open it. For more information, please refer to the documented guidelines for requesting features.