mirror of
https://github.com/django/django.git
synced 2025-09-23 02:33:31 +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:
parent
7a98442f96
commit
cbcf78fa94
2 changed files with 24 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue