Multi theme support for admin

80 views
Skip to first unread message

Ramez Ashraf

unread,
Dec 21, 2020, 12:00:34 PM12/21/20
to Django developers (Contributions to Django itself)
Hello Django Developers list

I'm sending on this thread to hopefully open a discussion about
Adding the ability for a multi custom theme in Django's Admin.

What do i mean ?
We can have many multiple Django admin sites, where each site can have its registered models, apps, admin views, etc.. ok?
However, 
Those different admin sites are limited to one interface/html structure, located at `tempates/admin`. A change in one admin site base.html will affect the other admin sites.

Proposal:
A way to direct each AdminSite to the template path where it should find the templates.

Example:
Add a setting called ADMIN_DEFAULT_THEME = 'admin'
Add an attribute to AdminSite called theme which default to ADMIN_DEFAULT_THEME, and basically this setting controls which directory this admin site look for templates.
So whenever a path like 'admin/some_file_name.html' occurs, it is to be replaced with something like f'{admin_theme}/some_file_name.html'
This will take effect in extends statements, AdminSite templates loading(index/app index / etc) and ModelAdmin template loading (change form/list/delete etc..)

Use case:
You want to be able to use the django admin default theme along with something like django-jazzmin along with Grappelli or django-suit.

Final thoughts:
* I see no real reason why we should not implement this.
* I sits well with the multi admin site idea. If we can have several different sites then they should be able to look different . 
* This open the door for admin theme to be something plug and play which in my opinion have some interesting nice outcomes

Finally, Thank you for your time reading this and i hope you support it or engage in a discussion.
Looking forward for your replies .. 


Matthias Kestenholz

unread,
Dec 21, 2020, 12:08:41 PM12/21/20
to django-d...@googlegroups.com
Hey,

I'm still working on https://github.com/django/django/pull/13435 , an attempt to use CSS variables to style the administration interface. Unfortunately, real life and (desired) deadlines from paid projects tend to interfere. I still very much intend to clean up the pull request which is getting quite close to getting merged, I hope.

Your proposal of not only changing colors but allowing different skins sounds like it would require (much) more effort and probably also more maintenance down the road. This may be a real world reason why we shouldn't implement this (I'm not saying it isn't a good idea!)

Best regards,
Matthias

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/f96a4b22-3ce3-4031-a97a-d3b406d788ccn%40googlegroups.com.


--
Feinheit AG - Matthias Kestenholz - Direkt +41 79 444 78 96 - Zentrale +41 555 11 11 41

Adam Johnson

unread,
Dec 21, 2020, 12:35:17 PM12/21/20
to django-d...@googlegroups.com
Ramez - one can switch themes on a per-site basis already by overriding AdminSite.each_context() to add style control variables, and overriding the "admin/base_site.html" template (and other templates) to conditionally include different CSS or elements. I know that such a solution is unlikely to allow using e.g. grappelli and Django-suit in the same project, but I don't think there will be any sane way to combine them at current since they rely on patching many different things in the existing admin files. It's unclear to me how a new setting would simplify the situation.

In my opinion, using multiple admins with completely different themes for different purposes is pushing the admin beyond its design goal of providing an internal data administration panel.

Matthias - your CSS variables PR is exciting. Looking forward to it, but do enjoy the holidays!



--
Adam
Reply all
Reply to author
Forward
0 new messages