So I propose we remove the `@import` in `admin/css/base.css` and replace
it with a `<link rel="stylesheet">` inside an overridable block in
`base.html`. Right now I called it `adminfonts` for lack of a better name.
With that in place, a project can extend `base_site.html`, empty out
`adminfonts` and add whatever color / font customizations in the existing
`extrastyle` block.
This change would also offer some greater flexibility for users to at
least improve the situation for themselves when it comes to Django’s
default international font challenges—see issue #29122, for instance.
--
Ticket URL: <https://code.djangoproject.com/ticket/29936>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* Attachment "admin-fonts.patch" added.
Patch for #29936 created on git master as of
75dfa92a05c7161edd0ba7bc9ceab9b54d3383db
* keywords: => css roboto fonts woff font
* cc: elky (added)
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/29936#comment:1>
Comment (by Tim Graham):
Couldn't you override the `fonts.css` static file?
--
Ticket URL: <https://code.djangoproject.com/ticket/29936#comment:2>
Comment (by Antonio Cavedoni):
Replying to [comment:2 Tim Graham]:
> Couldn't you override the `fonts.css` static file?
Not really, because it’s hardcoded through an `@import` rule into the
admin `base.css`. You could have your own copy of either `fonts.css` or
the `base.css` file, but one would lose the convenience of being able to
update Django with no modifications.
--
Ticket URL: <https://code.djangoproject.com/ticket/29936#comment:3>
Comment (by Antonio Cavedoni):
I created a pull request with the proposed change:
https://github.com/django/django/pull/10631
--
Ticket URL: <https://code.djangoproject.com/ticket/29936#comment:4>
Comment (by Tim Graham):
In the ticket description you said, a use case is to "empty out
adminfonts" -- is that different from overriding fonts.css with an empty
file? I'm still trying to understand a use case that requires the
additional template block.
--
Ticket URL: <https://code.djangoproject.com/ticket/29936#comment:5>
Comment (by Antonio Cavedoni):
It achieves the same thing but—I argue—in a more elegant way. Unless I’m
overlooking something obvious, overriding `fonts.css` with an empty file
essentially means maintaining one’s fork of Django. Even if it’s just
running a `ln -s` operation, it means having to do that after every Django
update / install. My solution avoids that by making the very import of
`fonts.css` an extendable (overridable) block so it can all be done at the
project / application level. Does that make the patch clearer?
--
Ticket URL: <https://code.djangoproject.com/ticket/29936#comment:6>
Comment (by Antonio Cavedoni):
(Whatever the outcome, thanks for your continued attention to this
admittedly minor issue, Tim.)
--
Ticket URL: <https://code.djangoproject.com/ticket/29936#comment:7>
Comment (by Tim Graham):
You can override a static file by creating one with the same path in an
app that comes before the admin in `INSTALLED_APPS`.
--
Ticket URL: <https://code.djangoproject.com/ticket/29936#comment:8>
Comment (by Carlton Gibson):
Or indeed using `STATICFILES_DIRS`. (With the default
`STATICFILES_FINDERS`, any files there will be found before any app
folders, so before `contrib.admin`’s)
--
Ticket URL: <https://code.djangoproject.com/ticket/29936#comment:9>
Comment (by Antonio Cavedoni):
Doesn’t that hold true only if you’re serving the static files via Django?
In other words, if you serve the admin static files via some other server,
Django isn’t even involved and no overriding can take place, correct?
--
Ticket URL: <https://code.djangoproject.com/ticket/29936#comment:10>
Comment (by Tim Graham):
Do you gather your static files without `collectstatic`?
--
Ticket URL: <https://code.djangoproject.com/ticket/29936#comment:11>
* status: new => closed
* resolution: => invalid
Comment:
I see, I wasn’t aware of the interaction between app loading / overriding
and collectstatic. Awesome! Thanks, Tim & Carlton, and sorry for the
noise.
--
Ticket URL: <https://code.djangoproject.com/ticket/29936#comment:12>
Comment (by Carlton Gibson):
#33878 (for Django 4.2) added `--font-family-primary` and `--font-family-
monospace` variables that can be overridden as per
[https://docs.djangoproject.com/en/dev/ref/contrib/admin/#theming-support
Theming support docs].
--
Ticket URL: <https://code.djangoproject.com/ticket/29936#comment:13>