diff options
| author | Tim Graham <timograham@gmail.com> | 2016-09-26 18:47:07 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-09-26 18:47:07 -0400 |
| commit | c47f8a9d4d2db79b85562266150adcf4e44319e9 (patch) | |
| tree | 34eefb3f43934d4b727107a7e96ac73a2078a468 | |
| parent | 85f2bba7ebd98fddaeb7451e733685022aae21cf (diff) | |
Removed obsolete lines in DeferredAttribute.__get__().
Obsolete as of c21e86ab9e3e5ebd6d245d038cb0cb352cd84c3a.
| -rw-r--r-- | django/db/models/query_utils.py | 11 |
1 files changed, 1 insertions, 10 deletions
diff --git a/django/db/models/query_utils.py b/django/db/models/query_utils.py index 111ba65f3c..fa245fcf07 100644 --- a/django/db/models/query_utils.py +++ b/django/db/models/query_utils.py @@ -10,7 +10,6 @@ from __future__ import unicode_literals import inspect from collections import namedtuple -from django.core.exceptions import FieldDoesNotExist from django.db.models.constants import LOOKUP_SEP from django.utils import tree from django.utils.lru_cache import lru_cache @@ -108,19 +107,11 @@ class DeferredAttribute(object): """ if instance is None: return self - opts = instance._meta data = instance.__dict__ if data.get(self.field_name, self) is self: - # self.field_name is the attname of the field, but only() takes the - # actual name, so we need to translate it here. - try: - f = opts.get_field(self.field_name) - except FieldDoesNotExist: - f = [f for f in opts.fields if f.attname == self.field_name][0] - name = f.name # Let's see if the field is part of the parent chain. If so we # might be able to reuse the already loaded value. Refs #18343. - val = self._check_parent_chain(instance, name) + val = self._check_parent_chain(instance, self.field_name) if val is None: instance.refresh_from_db(fields=[self.field_name]) val = getattr(instance, self.field_name) |
