Add a .select_related() to the document main tab to reduce the number

of DB queries, unfortunately it seems it doesn't really help with
Django 1.2.x due to a bug (Document inherits from DocumentInfo which
makes things a bit more complicated)
 - Legacy-Id: 5313
This commit is contained in:
Ole Laursen 2013-01-21 12:27:26 +00:00
parent ab6a7f85c0
commit 06f4ed4cf3

View file

@ -79,7 +79,7 @@ def render_document_top(request, doc, tab, name):
@decorator_from_middleware(GZipMiddleware)
def document_main(request, name, rev=None):
doc = get_object_or_404(Document, docalias__name=name)
doc = get_object_or_404(Document.objects.select_related(), docalias__name=name)
# take care of possible redirections
aliases = DocAlias.objects.filter(document=doc).values_list("name", flat=True)