mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Fixed #33931 -- Optimized calling of get_app_list with AdminSites index/app_index
This commit is contained in:
parent
e9fd2b5724
commit
652bb58a0c
@ -549,15 +549,15 @@ class AdminSite:
|
||||
Display the main admin index page, which lists all of the installed
|
||||
apps that have been registered in this site.
|
||||
"""
|
||||
app_list = self.get_app_list(request)
|
||||
|
||||
context = {
|
||||
**self.each_context(request),
|
||||
"title": self.index_title,
|
||||
"subtitle": None,
|
||||
"app_list": app_list,
|
||||
**(extra_context or {}),
|
||||
}
|
||||
context = self.each_context(request)
|
||||
context.update(
|
||||
{
|
||||
"title": self.index_title,
|
||||
"subtitle": None,
|
||||
"app_list": context["available_apps"],
|
||||
**(extra_context or {}),
|
||||
}
|
||||
)
|
||||
|
||||
request.current_app = self.name
|
||||
|
||||
@ -566,19 +566,23 @@ class AdminSite:
|
||||
)
|
||||
|
||||
def app_index(self, request, app_label, extra_context=None):
|
||||
app_list = self.get_app_list(request, app_label)
|
||||
context = self.each_context(request)
|
||||
app_list = [
|
||||
app for app in context["available_apps"] if app["app_label"] == app_label
|
||||
]
|
||||
|
||||
if not app_list:
|
||||
raise Http404("The requested admin page does not exist.")
|
||||
|
||||
context = {
|
||||
**self.each_context(request),
|
||||
"title": _("%(app)s administration") % {"app": app_list[0]["name"]},
|
||||
"subtitle": None,
|
||||
"app_list": app_list,
|
||||
"app_label": app_label,
|
||||
**(extra_context or {}),
|
||||
}
|
||||
context.update(
|
||||
{
|
||||
"title": _("%(app)s administration") % {"app": app_list[0]["name"]},
|
||||
"subtitle": None,
|
||||
"app_list": app_list,
|
||||
"app_label": app_label,
|
||||
**(extra_context or {}),
|
||||
}
|
||||
)
|
||||
|
||||
request.current_app = self.name
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user