From 4e8c26531925227872ce29bc0cdee3329be4a216 Mon Sep 17 00:00:00 2001 From: Jason Parrott Date: Thu, 17 Mar 2016 22:45:00 +0900 Subject: [1.9.x] Fixed #26373 -- Fixed reverse lookup crash with a ForeignKey to_field in a subquery. Backport of 4c1c93032f4a015cbb4b33958603d18ac43515b4 from master --- django/db/models/query.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'django') diff --git a/django/db/models/query.py b/django/db/models/query.py index cb02085cc5..3787e34abc 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -1113,7 +1113,7 @@ class QuerySet(object): # if they are set up to select only a single field. if len(self._fields or self.model._meta.concrete_fields) > 1: raise TypeError('Cannot use multi-field values as a filter value.') - else: + elif self.model != field.model: # If the query is used as a subquery for a ForeignKey with non-pk # target field, make sure to select the target field in the subquery. foreign_fields = getattr(field, 'foreign_related_fields', ()) -- cgit v1.3