summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorSimon Charette <charettes@users.noreply.github.com>2016-05-03 09:28:31 -0400
committerSimon Charette <charettes@users.noreply.github.com>2016-05-03 09:28:31 -0400
commit7ec330eeb96d0874949eacb8ed1bbb97e11807e1 (patch)
treeb949c3dc41eb6e432804c454412a2978589e4043 /django
parent8a47ba679d2da0dee74671a53ba0cd918b433e34 (diff)
Refs #26565 -- Errored nicely when using Prefetch with a values() queryset.
Thanks Maxime Lorant for the report and Anssi for the suggestion.
Diffstat (limited to 'django')
-rw-r--r--django/db/models/query.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/django/db/models/query.py b/django/db/models/query.py
index 03d12cfa08..1cf2a80994 100644
--- a/django/db/models/query.py
+++ b/django/db/models/query.py
@@ -1331,6 +1331,8 @@ class Prefetch(object):
self.prefetch_through = lookup
# `prefetch_to` is the path to the attribute that stores the result.
self.prefetch_to = lookup
+ if queryset is not None and queryset._iterable_class is not ModelIterable:
+ raise ValueError('Prefetch querysets cannot use values().')
if to_attr:
self.prefetch_to = LOOKUP_SEP.join(lookup.split(LOOKUP_SEP)[:-1] + [to_attr])