dsffdsdsf
This commit is contained in:
14
ADMIN-SIDEBAR-DEBUG.md
Normal file
14
ADMIN-SIDEBAR-DEBUG.md
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# Admin Sidebar Fix - Debug Log
|
||||||
|
|
||||||
|
## Last Change (sidebar_navigation fix attempt)
|
||||||
|
**What I did:** Added `context['sidebar_navigation'] = custom_apps` in `each_context()` method in site.py
|
||||||
|
**Why:** Unfold uses `sidebar_navigation` variable in templates, not `available_apps`
|
||||||
|
**Result:** FAILED - Main group pages show NO sidebar, subpages show default Django sidebar
|
||||||
|
|
||||||
|
## Current Fix Attempt
|
||||||
|
**What I did:** Reverted sidebar_navigation override, changed `show_all_applications: True` in settings.py
|
||||||
|
**Why:** Unfold's `get_sidebar_list()` builds sidebar_navigation from SIDEBAR.navigation config. When False, it expects navigation config. When True, it uses available_apps.
|
||||||
|
**Expected:** Custom sidebar shows on all pages using available_apps
|
||||||
|
|
||||||
|
## Root Cause
|
||||||
|
Unfold has two modes: custom navigation (show_all_applications=False) OR auto from apps (show_all_applications=True). We need the second mode with our custom get_app_list().
|
||||||
@@ -1,14 +1,13 @@
|
|||||||
"""
|
"""
|
||||||
Custom Admin Dashboard with Key Metrics
|
Custom Admin Dashboard with Key Metrics
|
||||||
"""
|
"""
|
||||||
from django.contrib.admin.views.decorators import staff_member_required
|
from django.contrib import admin
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.db.models import Count, Sum, Q
|
from django.db.models import Count, Sum, Q
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
|
||||||
|
|
||||||
@staff_member_required
|
|
||||||
def admin_dashboard(request):
|
def admin_dashboard(request):
|
||||||
"""Custom admin dashboard with operational metrics"""
|
"""Custom admin dashboard with operational metrics"""
|
||||||
|
|
||||||
@@ -182,4 +181,9 @@ def admin_dashboard(request):
|
|||||||
'alerts': alerts,
|
'alerts': alerts,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Merge with admin context to get sidebar and header
|
||||||
|
from igny8_core.admin.site import admin_site
|
||||||
|
admin_context = admin_site.each_context(request)
|
||||||
|
context.update(admin_context)
|
||||||
|
|
||||||
return render(request, 'admin/dashboard.html', context)
|
return render(request, 'admin/dashboard.html', context)
|
||||||
|
|||||||
@@ -21,16 +21,15 @@ class Igny8AdminSite(UnfoldAdminSite):
|
|||||||
index_title = 'IGNY8 Administration'
|
index_title = 'IGNY8 Administration'
|
||||||
|
|
||||||
def get_urls(self):
|
def get_urls(self):
|
||||||
"""Get admin URLs - dashboard available at /admin/dashboard/ but not default"""
|
"""Get admin URLs with dashboard available at /admin/dashboard/"""
|
||||||
|
from django.urls import path
|
||||||
|
from .dashboard import admin_dashboard
|
||||||
|
|
||||||
urls = super().get_urls()
|
urls = super().get_urls()
|
||||||
# Dashboard is available at /admin/dashboard/ if needed, but not redirecting by default
|
custom_urls = [
|
||||||
# from django.urls import path
|
path('dashboard/', self.admin_view(admin_dashboard), name='dashboard'),
|
||||||
# from .dashboard import admin_dashboard
|
]
|
||||||
# custom_urls = [
|
return custom_urls + urls
|
||||||
# path('dashboard/', self.admin_view(admin_dashboard), name='dashboard'),
|
|
||||||
# ]
|
|
||||||
# return custom_urls + urls
|
|
||||||
return urls
|
|
||||||
|
|
||||||
def each_context(self, request):
|
def each_context(self, request):
|
||||||
"""
|
"""
|
||||||
@@ -184,6 +183,15 @@ class Igny8AdminSite(UnfoldAdminSite):
|
|||||||
# regardless of app_label parameter (for consistent sidebar on all pages)
|
# regardless of app_label parameter (for consistent sidebar on all pages)
|
||||||
organized_apps = []
|
organized_apps = []
|
||||||
|
|
||||||
|
# Add Dashboard link as first item
|
||||||
|
organized_apps.append({
|
||||||
|
'name': '📊 Dashboard',
|
||||||
|
'app_label': '_dashboard',
|
||||||
|
'app_url': '/admin/dashboard/',
|
||||||
|
'has_module_perms': True,
|
||||||
|
'models': [],
|
||||||
|
})
|
||||||
|
|
||||||
for group_name, group_config in custom_groups.items():
|
for group_name, group_config in custom_groups.items():
|
||||||
group_models = []
|
group_models = []
|
||||||
|
|
||||||
|
|||||||
@@ -652,7 +652,7 @@ UNFOLD = {
|
|||||||
},
|
},
|
||||||
"SIDEBAR": {
|
"SIDEBAR": {
|
||||||
"show_search": True,
|
"show_search": True,
|
||||||
"show_all_applications": False, # Use custom app_list from Igny8AdminSite
|
"show_all_applications": True, # Let Unfold show our custom app_list
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user