From 73d5eb808435bcf27ebc935847196ac9e97b6ddc Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Fri, 23 Feb 2024 22:50:09 +0000 Subject: Fixed #35241 -- Cached model's full parent list. co-authored-by: Keryn Knight co-authored-by: Natalia <124304+nessita@users.noreply.github.com> co-authored-by: David Smith co-authored-by: Paolo Melchiorre --- django/db/models/sql/compiler.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'django/db/models/sql') diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py index 9a0d2eb4e7..b36125c762 100644 --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -1391,7 +1391,7 @@ class SQLCompiler: def _get_parent_klass_info(klass_info): concrete_model = klass_info["model"]._meta.concrete_model for parent_model, parent_link in concrete_model._meta.parents.items(): - parent_list = parent_model._meta.get_parent_list() + all_parents = parent_model._meta.all_parents yield { "model": parent_model, "field": parent_link, @@ -1402,7 +1402,7 @@ class SQLCompiler: # Selected columns from a model or its parents. if ( self.select[select_index][0].target.model == parent_model - or self.select[select_index][0].target.model in parent_list + or self.select[select_index][0].target.model in all_parents ) ], } -- cgit v1.3