1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Fixed #7497 -- Allowed overriding the order of apps and models in admin.

This commit is contained in:
adontz
2022-03-05 20:09:42 +04:00
committed by Mariusz Felisiak
parent d44951b36e
commit 2bee0b4328
5 changed files with 63 additions and 10 deletions

View File

@@ -35,6 +35,14 @@ class Admin2(admin.AdminSite):
def password_change(self, request, extra_context=None):
return super().password_change(request, {"spam": "eggs"})
def get_app_list(self, request, app_label=None):
app_list = super().get_app_list(request, app_label=app_label)
# Reverse order of apps and models.
app_list = list(reversed(app_list))
for app in app_list:
app["models"].sort(key=lambda x: x["name"], reverse=True)
return app_list
class UserLimitedAdmin(UserAdmin):
# used for testing password change on a user not in queryset