mirror of
https://github.com/django/django.git
synced 2025-10-09 14:59:24 +00:00
Fixed #36606 -- Optimized QuerySet.values_list(flat=True) without fields.
This commit is contained in:
parent
2336d5d33a
commit
2063c88c34
@ -1416,11 +1416,14 @@ class QuerySet(AltersData):
|
|||||||
def values_list(self, *fields, flat=False, named=False):
|
def values_list(self, *fields, flat=False, named=False):
|
||||||
if flat and named:
|
if flat and named:
|
||||||
raise TypeError("'flat' and 'named' can't be used together.")
|
raise TypeError("'flat' and 'named' can't be used together.")
|
||||||
if flat and len(fields) > 1:
|
if flat:
|
||||||
raise TypeError(
|
if len(fields) > 1:
|
||||||
"'flat' is not valid when values_list is called with more than one "
|
raise TypeError(
|
||||||
"field."
|
"'flat' is not valid when values_list is called with more than one "
|
||||||
)
|
"field."
|
||||||
|
)
|
||||||
|
elif not fields:
|
||||||
|
fields = [self.model._meta.concrete_fields[0].attname]
|
||||||
|
|
||||||
field_names = {f: False for f in fields if not hasattr(f, "resolve_expression")}
|
field_names = {f: False for f in fields if not hasattr(f, "resolve_expression")}
|
||||||
_fields = []
|
_fields = []
|
||||||
|
Loading…
x
Reference in New Issue
Block a user