mirror of
https://github.com/django/django.git
synced 2025-10-29 08:36:09 +00:00
Fixed #25252 -- Added friendly error message on incorrect .select_related() use
Using select_related() after .values() or .values_list() is not possible because .values() or .values_list() already got the values they need.
This commit is contained in:
@@ -843,6 +843,10 @@ class QuerySet(object):
|
||||
|
||||
If select_related(None) is called, the list is cleared.
|
||||
"""
|
||||
|
||||
if self._fields is not None:
|
||||
raise TypeError("Cannot call select_related() after .values() or .values_list()")
|
||||
|
||||
obj = self._clone()
|
||||
if fields == (None,):
|
||||
obj.query.select_related = False
|
||||
|
||||
Reference in New Issue
Block a user