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

Fixed #26983 -- Fixed isnull filtering on ForeignKey with to_field

Thanks weidwonder for the report.
This commit is contained in:
Claude Paroz
2016-08-02 17:27:45 +02:00
parent 7bc5274f6f
commit 272eccf7ff
3 changed files with 17 additions and 1 deletions

View File

@@ -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]