Package: django-admin-toolbox
This package provides bunch of useful tools for default django admin site, such as:SidebarSmart breadcrumbsAll configuration is held inADMIN_TOOLBOXdict that should be placed in yoursettings.pyfile.WarningThis package is still in development and all API is considered unstable. This means that anything may
change without notice and without backwards compatibility!InstallationInstall admin toolbox (if not installed already)addadmin_toolboxat the top of yourINSTALLED_APPS(at least abovedjango.contrib.admin)ConfigurationAll configuration of this application is held in one dictionary in django settings, namedADMIN_TOOLBOX. Below you
can see default configuration:ADMIN_TOOLBOX={'sidebar':{'default':('admin_toolbox.builders.AppsListBuilder',{}),},'breadcrumbs':'auto',}If you want to customize any setting, you don’t have to copy whole defaults. Anything that is not set, will be filled
in with default values.Below you can find description of how to configure each module.SidebarThis module adds sidebar to the left of standard django admin template. This module cannot be disabled for now, as other
modules depend on it’s configuration. Purpose of this sidebar is to replace default list of models in django admin with
something more customizable and useful.By default, sidebar will just contain categories for all apps with models inside of them, which just corresponds to
list of apps and models on standard django admin dashboard. But you can customize that menu using builders.sidebarelement insideADMIN_TOOLBOXsettings contains all defined menus (like forDATABASES, you can
specify more than one menu). For now, onlydefaultmenu is used, other ones will be ignored. Each menu consists of
root element. Each element is specified by tuple containing string and dictionary. String should be valid python dot
path to builder class, dictionary contains all default arguments that will be passed to that class when initializing.Each builder is one ofListBuilderorItemBuilderfromadmin_toolbox.buildersmodule or any subclass
of them. For root element, onlyListBuilderand it’s subclasses are allowed.Root element of each menu is a container for whole menu, but it’s logic is still invoked, but it won’t be rendered as
a whole, only it’s sub-items will be. How to nest items is explained below.Also, each element, except of root one, should have specified name (if specified builder cannot generate it
automatically).There is default limit for nesting set to 3 levels. It is enforced on template level, so if you want to create menu
with more nested levels, simply overwrite template (and probably CSS) and implement displaying more than 3 levels in it.Built-in buildersEach builder can takenameandiconparameter. For builders that cannot generatenameby themselves (by for
example taking them from model or app name),namemust be specified, unless builder is used as root elementListBuilderBuilder that contains sub-elements. It’s just a container, so by default, does nothing.nameargument is required if
not used as root element.itemsargument is required and should be a list or tuple of 2-tuples defined like root
element.ItemBuilderBuilder that represents simple url.nameargument is required.urlargument is required. It also can takepermissions_checkthat should be either callable or dotted path to callable that will return True or False
determining if user can see this option in menu. It should takerequest,contextandmenu_nameparameters.ModelBuilderBuilder that representsModelAdmin. It simply looks forModelAdminfor specified model and puts URL to it’s
changelist in menu.modelis required and should be in form ofapp_name.ModelNameorpath_to_app.ModelName,
there should be no.modelsinside path to model.nameis optional, if not provided will default to model’s
name. If icon is not provided, builder will try to get it from_menu_iconattribute of Model’sMetaclass and if
it fails, will default to one based on navigation level.ModelsBuilderBuilder that represents all model admins from specified app. It will scan for models in specified app and put them as
sub-elements, usingModelBuilderfor each of them. You can also specifyitemsthat can contain any sub-items.
Any sub-item manually specified initemswill come before items automatically added from scanning app. If Model or
path to Model admin is referenced initemsit will be automatically skipped later on, when creating automatic
list of app models, so every model is used only once. This is global behaviour for every URL You can also setmodelsorexcludeparameters that will limit which models should be used. They can’t be used together. Ifmodelsis used, only models specified inmodelswill be used.modelsandexcludeshould be just in form
of list of model names (without app name). As for model,nameis optional and if not provided, will default to
app name. Also, similarly to model, builder will try to fetch icon fromAppConfig’s_menu_iconattribute and
fall back to default one based on navigation level.AppsBuilderBuilder that represents all apps with their models. It will scan for apps in project and put every app as sub-item
usingModelsBuilder(which will build sub-item for every model in app). You can specifyappsandexcludewhich works likemodelsandexcludeinModelsBuilder, but instead put app names as list (without full path).
You can also specify single models inappsandexcludetogether with app names. Models should be in form ofapp_name.ModelName, models specified without app name will be treated like apps and may result in unexpected
behaviour.nameis required if item is not used as root item, because there is no place from which we can get
default name.iconmay be customized like in other items, but there is no special place for defining it.IconsYou can use any icon from font awesome icons in menu, just by providing it’s name. Version 4.6.2 is embedded, if you
need newer one, just edit base template and put there your own version (or replace font awesome files in staticfiles,
that works too). Icon can be defined in every builder, usingiconargument (icon for root element will be ignored,
for obvious reasons) or in case of models and apps (and usingModelBuilder,ModelsBuilderorAppsBuilder),
you can set default icon accordingly in modelsMetaor in appsAppConfigusing_menu_iconattribute. If no
icon is defined for particular item, it defaults to icon based on navigation level (angle-rightfor 1st level,angle-double-rightfor 2nd level and no icon for 3rd level).Smart BreadcrumbsThis module gives you ability to rewrite default admin breadcrumbs to match structure defined with admin menu.
Generation of smart breadcrumbs requiresbeautifulsoup4library, which you can install by installingdjango-admin-toolbox[smart-breadcrumbs].You can enable or disable this feature, by using'breadcrumbs'in settings dict. Allowed values are:None- Disables breadcrumbs alltogether. This option will hide default breadcrumbs generated by Django.'auto'- Breadcrumbs will be automatically enabled ifbeautifulsoup4is available. Otherwise, default django
admin breadcrumbs will be used.'auto-smart'- Breadcrumbs will be automatically enabled ifbeautifulsoup4is available. Otherwise, no
breadcrumbs will be used.'smart'- Breadcrumbs will be explicitly enabled. This option will trigger exception ifbeautifulsoup4is not
installed'force-smart'- Similar to'smart', but breadcrumbs will be also visible on pages, where they don’t exist
in default django admin.