From 77a45dc7bc6f0badb45ec043e85f1b542c52792e Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sun, 15 Dec 2013 13:33:50 -0600 Subject: Use select_related() in new mirror URL details view Signed-off-by: Dan McGee --- mirrors/views.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mirrors/views.py b/mirrors/views.py index b2e75b2..3433616 100644 --- a/mirrors/views.py +++ b/mirrors/views.py @@ -201,7 +201,8 @@ def mirror_details_json(request, name): def url_details(request, name, url_id): - url = get_object_or_404(MirrorUrl, id=url_id, mirror__name=name) + url = get_object_or_404(MirrorUrl.objects.select_related(), + id=url_id, mirror__name=name) mirror = url.mirror authorized = request.user.is_authenticated() if not authorized and \ @@ -209,7 +210,8 @@ def url_details(request, name, url_id): raise Http404 error_cutoff = timedelta(days=7) cutoff_time = now() - error_cutoff - logs = MirrorLog.objects.filter(url=url, check_time__gte=cutoff_time).order_by('-check_time') + logs = MirrorLog.objects.select_related('location').filter( + url=url, check_time__gte=cutoff_time).order_by('-check_time') context = { 'url': url, -- cgit v1.2.3-24-g4f1b