From 272eccf7ff0ced609e5a5e3bb6b4a40e773e0e66 Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Tue, 2 Aug 2016 17:27:45 +0200 Subject: Fixed #26983 -- Fixed isnull filtering on ForeignKey with to_field Thanks weidwonder for the report. --- django/db/models/fields/related_lookups.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'django') diff --git a/django/db/models/fields/related_lookups.py b/django/db/models/fields/related_lookups.py index 5454031c2a..de2564fb0d 100644 --- a/django/db/models/fields/related_lookups.py +++ b/django/db/models/fields/related_lookups.py @@ -93,7 +93,7 @@ class RelatedLookupMixin(object): # ForeignKey to IntegerField given value 'abc'. The ForeignKey itself # doesn't have validation for non-integers, so we must run validation # using the target field. - if hasattr(self.lhs.output_field, 'get_path_info'): + if self.prepare_rhs and hasattr(self.lhs.output_field, 'get_path_info'): # Get the target field. We can safely assume there is only one # as we don't get to the direct value branch otherwise. target_field = self.lhs.output_field.get_path_info()[-1].target_fields[-1] -- cgit v1.3