From efc1c73bf511cbebf03fa5b13fa3a98718daf928 Mon Sep 17 00:00:00 2001 From: Taoup Date: Wed, 29 Jan 2020 23:06:56 +0800 Subject: [PATCH] Simplified DeferredAttribute.__get__() a bit. --- django/db/models/query_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django/db/models/query_utils.py b/django/db/models/query_utils.py index 96409cc67ce..4c6c48bf9d3 100644 --- a/django/db/models/query_utils.py +++ b/django/db/models/query_utils.py @@ -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)