1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #28047 -- Fixed QuerySet.filter() crash when it uses the name of a OneToOneField pk.

Regression in 1bc249c2a6.
This commit is contained in:
Tim Graham
2017-04-10 09:47:26 -04:00
parent a19b373d89
commit fce7827101
3 changed files with 9 additions and 1 deletions

View File

@@ -83,7 +83,8 @@ class RelatedIn(In):
else:
if getattr(self.rhs, '_forced_pk', False):
self.rhs.clear_select_clause()
if getattr(self.lhs.output_field, 'primary_key', False):
if (getattr(self.lhs.output_field, 'primary_key', False) and
self.lhs.output_field.model == self.rhs.model):
# A case like Restaurant.objects.filter(place__in=restaurant_qs),
# where place is a OneToOneField and the primary key of
# Restaurant.