Code

Opened 5 years ago

Closed 5 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: UI/UX:

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

Download all attachments as: .zip

Change History (4)

Changed 5 years ago by kit1980

comment:1 Changed 5 years ago by anonymous

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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

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

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.