From 678c8dfee458cda77fce0d1c127f1939dc134584 Mon Sep 17 00:00:00 2001 From: alosultan Date: Mon, 8 Jun 2020 19:37:25 +0300 Subject: [PATCH] Fixed #31680 -- Removed unnecessary getattr() call in DeferredAttribute.__get__(). refresh_from_db() loads fields values. --- django/db/models/query_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/django/db/models/query_utils.py b/django/db/models/query_utils.py index 4c6c48bf9d..f7c6d74e72 100644 --- a/django/db/models/query_utils.py +++ b/django/db/models/query_utils.py @@ -147,8 +147,8 @@ class DeferredAttribute: val = self._check_parent_chain(instance) if val is None: instance.refresh_from_db(fields=[field_name]) - val = getattr(instance, field_name) - data[field_name] = val + else: + data[field_name] = val return data[field_name] def _check_parent_chain(self, instance):