prefetch labels

This commit is contained in:
AlanCoding
2017-02-03 22:55:34 -05:00
parent d9799d6f45
commit eb3b9d96ac
3 changed files with 13 additions and 5 deletions

View File

@@ -8,7 +8,7 @@ import logging
# Django
from django.conf import settings
from django.db.models import Q
from django.db.models import Q, Prefetch
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.utils.translation import ugettext_lazy as _
@@ -1868,6 +1868,7 @@ class UnifiedJobTemplateAccess(BaseAccess):
qs = qs.prefetch_related(
'last_job',
'current_job',
Prefetch('labels', queryset=Label.objects.all().order_by('name'))
)
# WISH - sure would be nice if the following worked, but it does not.