mirror of
https://github.com/django/django.git
synced 2024-12-23 01:25:58 +00:00
Refs #28459 -- Improved performance of Model.from_db() when fields are deferred.
This commit is contained in:
parent
7bd9639406
commit
78f7f68021
@ -489,9 +489,11 @@ class Model(metaclass=ModelBase):
|
||||
@classmethod
|
||||
def from_db(cls, db, field_names, values):
|
||||
if len(values) != len(cls._meta.concrete_fields):
|
||||
values = list(values)
|
||||
values.reverse()
|
||||
values = [values.pop() if f.attname in field_names else DEFERRED for f in cls._meta.concrete_fields]
|
||||
values_iter = iter(values)
|
||||
values = [
|
||||
next(values_iter) if f.attname in field_names else DEFERRED
|
||||
for f in cls._meta.concrete_fields
|
||||
]
|
||||
new = cls(*values)
|
||||
new._state.adding = False
|
||||
new._state.db = db
|
||||
|
Loading…
Reference in New Issue
Block a user