summaryrefslogtreecommitdiff
path: root/django/db/models/sql/query.py
diff options
context:
space:
mode:
authorHasan Ramezani <hasan.r67@gmail.com>2020-04-04 20:55:20 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-04-06 08:15:51 +0200
commit22a2e97fc30487af89d7c34b753853e7b510083d (patch)
treed38d8020bb1191c5d01108291f312655ba3211f2 /django/db/models/sql/query.py
parent810f18c2df4b268ac1908fdd0b43bbbf07bdea06 (diff)
[3.0.x] Fixed #31420 -- Fixed crash when filtering subquery annotation against a SimpleLazyObject.
Thanks Simon Charette for the solution and analysis. Backport of 4237050684427db45ea834fe89d9e11c0520201e from master
Diffstat (limited to 'django/db/models/sql/query.py')
-rw-r--r--django/db/models/sql/query.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
index 0e6828b0f1..638161afc2 100644
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -239,7 +239,8 @@ class Query(BaseExpression):
@property
def output_field(self):
if len(self.select) == 1:
- return self.select[0].field
+ select = self.select[0]
+ return getattr(select, 'target', None) or select.field
elif len(self.annotation_select) == 1:
return next(iter(self.annotation_select.values())).output_field