Opened 15 years ago

Closed 14 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

Description

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 15 years ago.

Download all attachments as: .zip

Change History (4)

by kit1980, 15 years ago

Attachment: extrahead.diff added

comment:1 by anonymous, 15 years ago

Agreed.

A practical example:

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

changelists.css
#changelist table thead th:first-child {
text-align:center;
width:1.5em;
}

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 by Luke Plant, 15 years ago

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 by kit1980, 14 years ago

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