pythondjangodjango-templatesdjango-admindjango-admin-tools

Need to group the apps under labels for the sidebar of django admin using the package jazzmin


I have managed to group the apps in the landaing page of dashboard. But in side bar it was not refelcting. i need to group the models in the side bar too.

i have used the jazzmin package as well as the admin_reorder

packages used are :- django-modeladmin-reorder==0.3.1 and django-reorder-admin==0.3.1


Solution

  • Create a custom middleware and add it in your settings file.

    from admin_reorder.middleware import ModelAdminReorder
    
    
    class ModelAdminReorderWithNav(ModelAdminReorder):
    
        def process_template_response(self, request, response):
    
            available_apps = response.context_data.get('available_apps')
    
            response.context_data['app_list'] = available_apps
    
            response = super().process_template_response(request, response)
    
            response.context_data['available_apps'] = response.context_data[
    
                'app_list'
    
            ]
    
            return response