[Fixed]-Users management unavailable in Django admin

1👍

Many 3rd party applications use default admin so your question concerns not only auth models. I’ve solved this problem like this:

# project_root/project/admin.py

from django.contrib.admin.sites import AdminSite, site

class CustomAdminSite(AdminSite):
    pass

admin_site = CustomAdminSite()

# registering to custom admin site all the models from default admin site
for model_cls, admin_obj in list(site._registry.items()):
    admin_site.register(model_cls, type(admin_obj))

Also from my experience I wanted to note that custom admin site is rarely needed because almost everything can be customized for the default one. So now in my projects I prefer to do like this:

# project_root/project/admin.py

from django.contrib import admin

admin.site.site_header = 'Custom header'
admin.site.site_title = admin.site.site_header
admin.site.index_title = 'Custom index title'
admin.site.index_template = 'admin/custom_index.html'
admin.site.app_index_template = 'admin/custom_app_index.html'

…etc. https://docs.djangoproject.com/en/1.8/ref/contrib/admin/#adminsite-objects

👤alTus

Leave a comment