From 24cc51f8fb62102a67d16cef1e0748d45afe25f4 Mon Sep 17 00:00:00 2001 From: Keryn Knight Date: Wed, 24 Nov 2021 11:58:13 +0000 Subject: [PATCH] Refs #27624 -- Optimized Query.clone() a bit. --- django/db/models/sql/query.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index 1faf98d45d..31a66cec46 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -344,11 +344,8 @@ class Query(BaseExpression): obj.subq_aliases = self.subq_aliases.copy() obj.used_aliases = self.used_aliases.copy() obj._filtered_relations = self._filtered_relations.copy() - # Clear the cached_property - try: - del obj.base_table - except AttributeError: - pass + # Clear the cached_property, if it exists. + obj.__dict__.pop("base_table", None) return obj def chain(self, klass=None):