I was trying to rearrange the order of models and apps displayed in Django admin panel.
For that I overrode the function get__app__list()
function which is defined in Django package mentioned below.
from django.contrib.admin import AdminSite
class CustomAdminSite(AdminSite):
def get_app_list(self, request, app_label=None):
"""
Return a sorted list of all the installed apps that have been
registered in this site.
"""
app_dict = self._build_app_dict(request, app_label)
ordering_dict = {'AUTH':1,USERS': 1,'COURSE': 2,}
# Sort the apps based on ordering_dict
app_list =sorted(app_dict.values(),key=lambdax:ordering_dict.get(x["name"].upper(),float('inf')))
return app_list
admin.site = CustomAdminSite()
I tried this in admin.py of all my apps.
When I used the same code in inside Django library (by rewriting inside the package), it worked perfectly.
But if I inherited the AsminSite and overrode the function get__app__list()
:
the object of auth app is not in request,
so the GROUP table is missing in admin panel,
How the object is not there when I inherit and override it?
I want to know how the object is not there when I inherit and override it.
What can I do instead?