1
0
mirror of https://github.com/django/django.git synced 2024-12-23 01:25:58 +00:00

Simplified DeferredAttribute.__get__() a bit.

This commit is contained in:
Taoup 2020-01-29 23:06:56 +08:00 committed by GitHub
parent 1a9459b88e
commit efc1c73bf5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -141,7 +141,7 @@ class DeferredAttribute:
return self
data = instance.__dict__
field_name = self.field.attname
if data.get(field_name, self) is self:
if field_name not in data:
# 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)