From ea72cea06e7e78c15b2b3248d44f9684cf6268de Mon Sep 17 00:00:00 2001 From: Seth Denner Date: Wed, 15 Feb 2017 17:07:09 -0800 Subject: [PATCH] Fix get_selected_fields for Django 1.8 * The way selected fields are aggregated has been refactored so that only query.select contains the selected fields and the field object is in the target attribute instead of the info attribute. I made these changes and cased it specifically for Django 1.8 leaving the legacy implementations intact. --- djangotoolbox/db/basecompiler.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/djangotoolbox/db/basecompiler.py b/djangotoolbox/db/basecompiler.py index d49a4f9..a1ddd4e 100644 --- a/djangotoolbox/db/basecompiler.py +++ b/djangotoolbox/db/basecompiler.py @@ -28,13 +28,21 @@ class EmptyResultSet(Exception): else: from django.db.models.sql.constants import LOOKUP_SEP -if django.VERSION >= (1, 6): +if django.VERSION >= (1, 8): + def get_selected_fields(query): + if query.select: + return [info.target for info in query.select] + else: + return query.model._meta.fields + +elif django.VERSION >= (1, 6): def get_selected_fields(query): if query.select: return [info.field for info in (query.select + query.related_select_cols)] else: return query.model._meta.fields + else: def get_selected_fields(query): if query.select_fields: