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.
sites
app before theauth
app - Rename app labels easily for third party apps without having to modify the source code. e.g. rename
auth
app toAuthorisation
for the django admin app. - Split large apps into smaller groups of models.
- Reorder models within an app. e.g.
auth.User
model before theauth.Group
model. - Exclude any of the models from the app list. e.g. Exclude
auth.Group
from 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.Site
model to theauth
app. - Rename individual models in the app list. e.g. rename
auth.User
fromUser
toStaff
The full documentation is at https://django-modeladmin-reorder.readthedocs.org.
Install django-modeladmin-reorder:
pip install django-modeladmin-reorder
Add 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'}, )}, )
Add admin_reorder to INSTALLED_APPS:
INSTALLED_APPS = ( ... 'admin_reorder', ... )
Create your own middleware inherited from ModelAdminReorderMiddlewareMixin, define settings_variable_name and methods get_admin_site and get_admin_site_url_names
from admin_reorder.middleware import ModelAdminReorderMiddlewareMixin from PROJECT_NAME.admin import short_admin_site class ReorderShortAdminSiteMiddleware(ModelAdminReorderMiddlewareMixin): settings_variable_name = 'SHORT_ADMIN_REORDER' def get_admin_site(self): return short_admin_site def get_admin_site_url_names(self): names = super().get_admin_site_url_names() names.append('short_admin_index') return names
Add the ReorderShortAdminSiteMiddleware to MIDDLEWARE_CLASSES:
MIDDLEWARE_CLASSES = ( ... 'PROJECT_NAME.middleware.ReorderShortAdminSiteMiddleware', ... )