This commit is contained in:
IGNY8 VPS (Salman)
2025-12-14 22:21:17 +00:00
parent 9150b60c2d
commit f637f700eb
11 changed files with 1565 additions and 58 deletions

View File

@@ -21,18 +21,29 @@ class Igny8AdminSite(UnfoldAdminSite):
index_title = 'IGNY8 Administration'
def get_urls(self):
"""Get admin URLs without custom dashboard"""
"""Get admin URLs - dashboard available at /admin/dashboard/ but not default"""
urls = super().get_urls()
# Dashboard is available at /admin/dashboard/ if needed, but not redirecting by default
# from django.urls import path
# from .dashboard import admin_dashboard
# custom_urls = [
# path('dashboard/', self.admin_view(admin_dashboard), name='dashboard'),
# ]
# return custom_urls + urls
return urls
def each_context(self, request):
"""
Override context to ensure our custom app_list is always used
This is called by all admin templates for sidebar rendering
CRITICAL FIX: Force custom sidebar on ALL pages including model detail/list views
"""
context = super().each_context(request)
# Force our custom app list to be used everywhere
context['available_apps'] = self.get_app_list(request)
# Force our custom app list to be used everywhere - IGNORE app_label parameter
custom_apps = self.get_app_list(request, app_label=None)
context['available_apps'] = custom_apps
context['app_list'] = custom_apps # Also set app_list for compatibility
return context
def get_app_list(self, request, app_label=None):
@@ -42,10 +53,10 @@ class Igny8AdminSite(UnfoldAdminSite):
Args:
request: The HTTP request
app_label: Optional app label to filter (used for app index pages)
app_label: IGNORED - Always return full custom sidebar for consistency
"""
# Get the default app list
app_dict = self._build_app_dict(request, app_label)
# CRITICAL: Always build full app_dict (ignore app_label) for consistent sidebar
app_dict = self._build_app_dict(request, None)
# Define our custom groups with their models (using object_name)
# Organized by business function - Material icons configured in Unfold