Custom ordering for the apps and models in the admin app. You can also rename, cross link or exclude models from the app list.
- Reorder apps in admin index - this will allow you to position most used apps in top of the page, instead of listing apps alphabetically. e.g.
sitesapp before theauthapp - Rename app labels easily for third party apps without having to modify the source code. e.g. rename
authapp toAuthorisationfor the django admin app. - Split large apps into smaller groups of models.
- Reorder models within an app. e.g.
auth.Usermodel before theauth.Groupmodel. - Exclude any of the models from the app list. e.g. Exclude
auth.Groupfrom the app list. Please note this only excludes the model from the app list and it doesn't protect it from access via url. - Cross link models from multiple apps. e.g. Add
sites.Sitemodel to theauthapp. - Rename individual models in the app list. e.g. rename
auth.UserfromUsertoStaff - Support custom admin model
- Adds all of the above to Django 3.1 Admin Sidebar
The full documentation is at https://django-modeladmin-reorder.readthedocs.org.
Install django-modeladmin-reorder:
pip install git+https://github.com/KyleOng/django-modeladmin-reorder.gitAdd admin_reorder to INSTALLED_APPS:
INSTALLED_APPS = ( ... 'admin_reorder', ... )
Add the ModelAdminReorder to MIDDLEWARE_CLASSES:
MIDDLEWARE_CLASSES = ( ... 'admin_reorder.middleware.ModelAdminReorder', ... )
Add the setting ADMIN_REORDER to your settings.py:
ADMIN_REORDER = ( # Keep original label and models 'sites', # Rename app {'app': 'auth', 'label': 'Authorisation'}, # Reorder app models {'app': 'auth', 'models': ('auth.User', 'auth.Group')}, # Exclude models {'app': 'auth', 'models': ('auth.User', )}, # Cross-linked models {'app': 'auth', 'models': ('auth.User', 'sites.Site')}, # models with custom name {'app': 'auth', 'models': ( 'auth.Group', {'model': 'auth.User', 'label': 'Staff'}, )}, )
If you override the default admin site object (django.contrib.admin.site), add the setting ADMIN_REORDER_SITE to your settings.py:
# my_project/admin.py from django.contrib import admin class CustomAdminSite(admin.AdminSite): pass custom_admin = CustomAdminSite(name='CustomAdmin') # my_project/urls.py from my_project.admin import custom_admin urlpatterns = [ # ... path('/admin', custom_admin.urls), # ... ] # my_project/settings.py ADMIN_REORDER_SITE = 'my_project.admin.custom_admin'