From 8a99a7d2d5c3da6301bb41bf0fa8336736637cdb Mon Sep 17 00:00:00 2001 From: Sergey Fedoseev Date: Tue, 15 Aug 2017 18:48:07 +0500 Subject: [PATCH] Simplified RelatedPopulator.populate(). --- django/db/models/query.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/django/db/models/query.py b/django/db/models/query.py index f6fe830ace..0f55268b18 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -1704,12 +1704,12 @@ class RelatedPopulator: obj = None else: obj = self.model_cls.from_db(self.db, self.init_list, obj_data) - if obj and self.related_populators: - for rel_iter in self.related_populators: - rel_iter.populate(row, obj) + if self.related_populators: + for rel_iter in self.related_populators: + rel_iter.populate(row, obj) + if self.remote_field: + self.remote_field.set_cached_value(obj, from_obj) self.field.set_cached_value(from_obj, obj) - if obj and self.remote_field: - self.remote_field.set_cached_value(obj, from_obj) def get_related_populators(klass_info, select, db):