From 8b5489bc6f6fdf81b1f7458bc983db4f3a9ea41c Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Fri, 18 Feb 2022 13:18:36 -0500 Subject: [PATCH] [rentals] Use `select_related` in LockerInfo admin to improve load times --- rentals/admin.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rentals/admin.py b/rentals/admin.py index 4c88c55..640ad72 100644 --- a/rentals/admin.py +++ b/rentals/admin.py @@ -30,3 +30,6 @@ class LockerInfoAdmin(admin.ModelAdmin): list_filter = ["locker_unit__bank", "locker_unit", "renter"] list_display = ["locker_unit", "address", "blind_code", "bitting_code", "renter"] list_display_links = ["locker_unit", "address"] + + def get_queryset(self, request): + return LockerInfo.objects.select_related("locker_unit", "locker_unit__bank")