Package: django-admin-global-sidebar
django-admin-global-sidebarDescriptionProvides a configurable left navigation bar for Django's admin site.FeaturesConfigurable left navigation bar.Support two-level menus.Support navigation bar folding.Support menu item permission control.Expand the primary menu and highligh the secondary menu automatically according to the current page path.CSS-style icon display for menu items.PreviewsTwo-level navigationFolded navigationInstallpipinstalldjango-admin-global-sidebarUsageUsingdjango-admin-global-sidebarwill disable Django's default left navigation bar, which shipped with version 3.x.Add dependency packages toINSTALLED_APPSin filepro/settings.py.DefineDJANGO_ADMIN_GLOBAL_SIDEBAR_MENUSin filepro/settings.py. IfDJANGO_ADMIN_GLOBAL_SIDEBAR_MENUSis not defined, no navigation bar will be displayed.pro/settings.pyINSTALLED_APPS=[...'django_static_fontawesome','django_static_jquery3','django_admin_global_sidebar',...]DJANGO_ADMIN_GLOBAL_SIDEBAR_MENUS=[{"title":"Home","icon":"fa fa-home","url":"/admin/",},{"title":"Manage Books","icon":"fa fa-book","children":[{"title":"Manage Categories","icon":"fas fa-list","model":"django_admin_global_sidebar_example.category","permissions":["django_admin_global_sidebar_example.view_category"],},{"title":"Manage Books","icon":"fas fa-book","model":"django_admin_global_sidebar_example.book","permissions":["django_admin_global_sidebar_example.view_book"],}]},{"title":"Authenticate","icon":"fa fa-cogs","children":[{"title":"Manage Users","icon":"fas fa-user","model":"auth.user","permissions":["auth.view_user",],},{"title":"Manage Groups","icon":"fas fa-users","model":"auth.group","permissions":["auth.view_group",],}]},]DJANGO_ADMIN_GLOBAL_SIDEBAR_MENUSTwo-level menus supported.Menu item config options:titleis the display title.iconis fontawesome class.childrenis sub-menu list settings.url,modelorviewwill be used to calc the menu link. Only one option will be applied.urlmeans a fixed link.modelmeans model's changelist view.viewmeans django's view name and the result link is calced with: revered(view).permissionsis the permission array.Usingorlogic for permission elements.A permission element can be a permission-tag or permission-tags.Usingandlogic for permission-tags.active_patternsused to determine the active status of the menu item.Pattern will be used to test against the request.path.It can be a pattern string or pattern string list.Useorlogic for patterns.Advanced UsageDefine a navigation loading function and bind it toDJANGO_ADMIN_GLOBAL_SIDEBAR_MENUSYou can set theDJANGO_ADMIN_GLOBAL_SIDEBAR_MENUSvariable in file 'pro/settings.py' as a fixed menu list, you can also set the 'DJANGO_ADMIN_GLOBAL_SIDEBAR_MENUS' variable as the import path of the Menus-Loading-Function. For example, setDJANGO_ADMIN_GLOBAL_SIDEBAR_MENUS="app.menus.get_ menus_ by_ user". Here the string "app. menus.get_menus_by_user" is the import path of the function, which can be loading through 'magic_import.import_from_string'. The menu loading function accepts the unique parameter 'request' and returns the menu list. The format of the returned menu list is the same as fixed menu list that assgined to the variable 'DJANGO_ADMIN_GLOBAL_SIDEBAR_MENUS'. For example, define the following functions in 'app/menus.py':def get_menus_by_user(request):
    user_type = get_user_type(request.user)
    if user_type == MANAGER:
         return [{
             "title": "System Manage",
             ...
             "children": [{
                 "title": "Account Manage",
                 ...
             },{
                 "title": "Permission Manage",
                 ...
             }]
         }]
    elif user_type == READER:
        return [{
            "title": "Reader Center",
            ...
            "children": [{
                "title": "Card Manage",
                ...
            }]
        }]
    else:
        return []The code above will display different menus according to current user type. If current user is a site administrator, then it will show Manager's menu list. If current user is a reader, then it will show Reader's menu list.Load navigation from databaseThe Menus-Loading-Function is called in the admin site rendering. At that time the database engine is already loaded, so you can access the database to fetch menus dynamiclly.Navigation with i18n supportWhen loadingpro/settings.py, the i18n service is not ready, so that you can not useugettext_xxxfunctions. If you want to add i18n support for menu items, you can setDJANGO_ADMIN_GLOBAL_SIDEBAR_MENUSto a Menus-Loading-Function importing path, in the loading function you you can useugettext_xxxfunctions freely.Releasesv0.1.0First release.v0.1.1Fix popup problem.v0.1.2Depends on django-static-jquery3>=5.0.0.v0.1.3Add django_app_requires support.v0.1.4Force to disable nav-sidebar for Django3.2.Fix global sidebar height in long page.v0.2.0Fix problem that the page will scroll when clicking on primary menu items.You can setDJANGO_ADMIN_GLOBAL_SIDEBAR_MENUSto Menus-Loading-Function importing path.v0.2.1Fix sidebar height.v0.2.2Doc update.