Removed obsolete lines in DeferredAttribute.__get__().

Obsolete as of c21e86ab9e.
This commit is contained in:
Tim Graham 2016-09-26 18:47:07 -04:00 committed by GitHub
parent 85f2bba7eb
commit c47f8a9d4d
1 changed files with 1 additions and 10 deletions

View File

@ -10,7 +10,6 @@ from __future__ import unicode_literals
import inspect import inspect
from collections import namedtuple from collections import namedtuple
from django.core.exceptions import FieldDoesNotExist
from django.db.models.constants import LOOKUP_SEP from django.db.models.constants import LOOKUP_SEP
from django.utils import tree from django.utils import tree
from django.utils.lru_cache import lru_cache from django.utils.lru_cache import lru_cache
@ -108,19 +107,11 @@ class DeferredAttribute(object):
""" """
if instance is None: if instance is None:
return self return self
opts = instance._meta
data = instance.__dict__ data = instance.__dict__
if data.get(self.field_name, self) is self: 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 # 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. # 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: if val is None:
instance.refresh_from_db(fields=[self.field_name]) instance.refresh_from_db(fields=[self.field_name])
val = getattr(instance, self.field_name) val = getattr(instance, self.field_name)