-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Settings for multiple UnfoldAdminSites #768
Comments
This is something what I was already playing with and right now there should be a partial support for this in Unfold: https://github.com/unfoldadmin/django-unfold/blob/main/src/unfold/sites.py#L21 https://github.com/unfoldadmin/django-unfold/blob/main/src/unfold/settings.py#L57-L58 Anyway, this needs definitely more testing to polish edge cases and there are few things which will NOT work. |
I'm already stuck on this issue. For multiple UnfoldAdminSites , I always have "Reverse for 'app_model_changelist' not found." issues with my projects. In order to find out if my code is the reason, I re-created a test project, which only has two models, the user and the group of django. Strictly follow the official example, or this problem does not arise. [Without the settings-UNFOLD setup and the multiple UnfoldAdminSites setup, the program runs normally.] django 4.2.16 I follow this:
The test project is as simple as creating a new Django project and importing Unfold. I wonder if I'm missing something, please guide. I need to migrate my project to Django unfold! Thank you so much! |
@lukasvinclav your approach seems to be simpler to implement with the multiple top level settings key instead of nested keys. What things do you think will not work? Maybe we can define some tests. I have currently my approach ( SITE_CONFIG in UNFOLD stting ) implemented in one of my projects and i havent entcountered any issues yet ( still not using every feature, just own SIDEBAR and TABs and custom pages for the admins ) @Huanghibo for the second issue: |
Is it a third party application feature request?
No
Describe your feature request
Afaik there is currently no default way to use multiple UnfoldAdminSite instances with different settings:
`class TenantAdminSite(UnfoldAdminSite):
site_header = _("Tenant administration")
class SuperAdminSite(UnfoldAdminSite):
site_header = _("Super Administration")
admin_site = TenantAdminSite(name="tenantadmin")
super_admin_site = SuperAdminSite(name="superadmin")`
For example, using different sidebar configurations for each UnfoldAdminSite
My suggestion is to introduce a new optional setting "SITE_CONFIGS" eg
`"UNFOLD": {
"SIDEBAR": ... # default configuration
...
"SITE_CONFIGS": {
"SUPERADMIN": { "SIDEBAR": ..., # site specific configuration
"TABS: ... , },
"TENANTADMIN": { ... },
}
}`
In the UnfoldAdminSite, instead of calling get_config() directly, call a function that wraps the get_config() call thats tries to load from the optional site specific config first and if no such setting for the current AdminSite name is available, fall back to the default behaviour.
A point to discuss would be if all required settings should be defined in the site configuration. A other possible way would be site specific configuation would overlap the the default configuration, so common things can be configured in the default configuration, while certain options can be overidden in the site configuration.
I am not sure if this is too much of a border case as most projects just use one admin site but if there is interest i can provide a PR.
The text was updated successfully, but these errors were encountered: