mirror of
https://github.com/django/django.git
synced 2025-09-24 19:23:03 +00:00
Fixed #26373 -- Fixed reverse lookup crash with a ForeignKey to_field in a subquery.
This commit is contained in:
parent
8b5a4fa941
commit
4c1c93032f
3 changed files with 9 additions and 1 deletions
|
@ -1132,7 +1132,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', ())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue