Hi all,
I'm working to ticket #8500 and #27728 to improve a bit the admin, and being asked to ask to django-developers about some decision.
In ticket #8500 I've used a LazyObject to defer the the real django.contrib.admin.sites.site instantiation, so admin.site is always the custom one.
The first approach was simpler, with a setting. But as Tim pointed out it doesn't need to be a setting, so I rewrote to be a custom field for (Simple)AdminConfig (and django itself doesn't need to know it existence)
> class FluoAdminConfig(AdminConfig):
> default_site = "fluo.admin.sites.AdminSite"
>
> def ready(self):
> self.override_admin_site()
> super().ready()
>
> def override_admin_site(self):
> from django.contrib import admin as django_admin
> from django.contrib.admin import sites as django_sites
> from fluo import admin as fluo_admin
> from fluo.admin.sites import DefaultAdminSite
>
> site = DefaultAdminSite()
where the DefaultAdminSite is the same as in PR
> class DefaultAdminSite(LazyObject):
> def _setup(self):
> AdminSiteClass = import_string(apps.get_app_config('admin').default_site)
> self._wrapped = AdminSiteClass()
- it doesn't require to rewrite your admin.py to add an helper function in admin.py
> def register(site):
> site.register(...)
- it works with all current third party modules (so don't have to add a custom adapter in my own project)
- can use the @admin.register() decorator as is
Currently all my projects use this approach, and I'm really happy because I find no problem with 3rd apps, they always use my custom instance, and don't have two different site.
In ticket #27728 I've rewrite all include template tags (submit_row, pagination, admin_actions, search_form, date_hierarchy, result_list, prepopulated_fields_js, object_tools) to be overridable by the "standard" admin pattern (["admin/app_label/app_model/template_name", "admin/app_label/template_name", "admin/template_name"]).
This patch solves even the tickets #11974, #12566, #18957, #19235, #26763.
Choose to patch all include tags because:
- I have a project where I override all of them (!)
- they are all the same implementation, so easy to replicate
The approach is to create a custom InclusionAdminNode, which handle all common task to split the include parameters, select the correct template and wrapping the original tag function (which are never changed).
Hope this clears all intentions and have them in django 2.0 :)
--