mirror of
https://github.com/django/django.git
synced 2025-09-18 06:59:12 +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):
|
||||
if flat and named:
|
||||
raise TypeError("'flat' and 'named' can't be used together.")
|
||||
if flat and len(fields) > 1:
|
||||
raise TypeError(
|
||||
"'flat' is not valid when values_list is called with more than one "
|
||||
"field."
|
||||
)
|
||||
if flat:
|
||||
if len(fields) > 1:
|
||||
raise TypeError(
|
||||
"'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")}
|
||||
_fields = []
|
||||
|
Loading…
x
Reference in New Issue
Block a user