summaryrefslogtreecommitdiff
path: root/packages/admin.py
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2013-01-22 17:20:41 -0700
committerDan McGee <dan@archlinux.org>2013-01-22 17:20:41 -0700
commit85dc9d6df9f9038be6049aefbf8eb9ea94f9f23c (patch)
tree65054dc7761dc2aef30c6c354c1cea50ec9c0b0c /packages/admin.py
parent2c958511c41f53fb7de49ed4662eec966e0b76a5 (diff)
Override the default admin queryset for some models
Because some attributes are optional or otherwise not auto-magically picked up by Django, we can help the performance of loading these pages a lot by forcing a select_related() on the queryset used by the admin. For something like signoff_specifications, this drops the query count from ~107 to 9 queries. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'packages/admin.py')
-rw-r--r--packages/admin.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/packages/admin.py b/packages/admin.py
index 5e32dbb4..820bbb29 100644
--- a/packages/admin.py
+++ b/packages/admin.py
@@ -3,6 +3,7 @@ from django.contrib import admin
from .models import (PackageRelation, FlagRequest,
Signoff, SignoffSpecification, Update)
+
class PackageRelationAdmin(admin.ModelAdmin):
list_display = ('pkgbase', 'user', 'type', 'created')
list_filter = ('type', 'user')
@@ -19,6 +20,10 @@ class FlagRequestAdmin(admin.ModelAdmin):
ordering = ('-created',)
date_hierarchy = 'created'
+ def queryset(self, request):
+ qs = super(FlagRequestAdmin, self).queryset(request)
+ return qs.select_related('repo', 'user')
+
class SignoffAdmin(admin.ModelAdmin):
list_display = ('pkgbase', 'full_version', 'arch', 'repo',
@@ -28,6 +33,7 @@ class SignoffAdmin(admin.ModelAdmin):
ordering = ('-created',)
date_hierarchy = 'created'
+
class SignoffSpecificationAdmin(admin.ModelAdmin):
list_display = ('pkgbase', 'full_version', 'arch', 'repo',
'user', 'created', 'comments')
@@ -36,6 +42,10 @@ class SignoffSpecificationAdmin(admin.ModelAdmin):
ordering = ('-created',)
date_hierarchy = 'created'
+ def queryset(self, request):
+ qs = super(SignoffSpecificationAdmin, self).queryset(request)
+ return qs.select_related('arch', 'repo', 'user')
+
class UpdateAdmin(admin.ModelAdmin):
list_display = ('pkgname', 'repo', 'arch', 'action_flag',