Skip to content

Commit

Permalink
Merge pull request #282 from co-cddo/bug/DEV_319-fix-n+1-query
Browse files Browse the repository at this point in the history
Load the related objects eagerly.
  • Loading branch information
dhvander authored Sep 20, 2024
2 parents 3222d30 + 0d5a4cc commit 2f8bf0e
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions request_a_govuk_domain/request/admin/model_admins.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,15 @@ class ReviewAdmin(SimpleHistoryAdmin, FileDownloadMixin, admin.ModelAdmin):
model = Review
form = ReviewForm
change_form_template = "admin/review_change_form.html"
list_select_related = [
"application",
"application__owner",
"application__last_updated_by",
"application__registrar_person",
"application__registrant_person",
"application__registrant_org",
"application__registrar_org",
]

list_display = (
"get_reference",
Expand Down Expand Up @@ -516,6 +525,14 @@ class ApplicationAdmin(
django.db.models.fields.files.FileField: {"widget": CustomAdminFileWidget},
}
actions = ["export", "archive"]
list_select_related = [
"owner",
"last_updated_by",
"registrar_person",
"registrant_person",
"registrant_org",
"registrar_org",
]

def download_file_view(self, request, object_id, field_name):
application = self.model.objects.get(id=object_id)
Expand Down

0 comments on commit 2f8bf0e

Please sign in to comment.