Opened 10 years ago

Closed 10 years ago

#10990 closed (wontfix)

Admin templates that extend base_site.html and override extrahead or extrastyle should include block.super last

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


Admin templates that extend base_site.html and override extrahead or extrastyle (change_form.html, change_list.html, index.html, login.html, auth/user/change_password.html) should include block.super in extrahead or extrastyle blocks after their own additional .css or .js files, so files from user-changed base_site.html's extrahead or extrastyle blocks appear last in generated html code and thus override default values.

For example, I customized function URLify() from urlify.js a bit to remove more small words (non-English prepositions) and customized admin/base_site.html (put it in my project's template directory) by putting '<script src="{{ MEDIA_URL }}js/my_urlify.js" type="text/javascript"></script>' in extrahead block. I want this line to appear in html code after standard urlify.js to override the default behaviour.

Similar for css.

This change will change nothing for users who don't customize admin base_site.html

Attachments (1)

extrahead.diff (4.1 KB) - added by kit1980 10 years ago.

Download all attachments as: .zip

Change History (4)

Changed 10 years ago by kit1980

Attachment: extrahead.diff added

comment:1 Changed 10 years ago by anonymous


A practical example:

On a change_list where admin actions are diabled. This style is dominant:

#changelist table thead th:first-child {

This renderst he first element block pretty tight in some cases, making it somewhat silly to look at. It is not possible to override this with your custom CSS without making the above mentioned adjustments.

comment:2 Changed 10 years ago by Luke Plant

This is not necessarily a simple decision -- what if the admin templates are themselves overriding CSS that is included in base_site.html (or want to in the future)? Or if a developer wants to inherit from one of the 'lower' templates and do CSS/javascript overriding, rather than customise base_site.html?

For CSS, an alternative solution is !important declarations. For javascript, can you do some hackery where my_urlify.js waits for the page to load and then monkey patches? I just want to investigate alternatives...

comment:3 Changed 10 years ago by kit1980

Resolution: wontfix
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top