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

Fixed #30477 -- Made reverse lookup use Field.get_db_prep_value() from the target field.

This commit is contained in:
can
2019-06-24 18:48:10 +03:00
committed by Mariusz Felisiak
parent 76b993a117
commit 325d5d6445
3 changed files with 29 additions and 14 deletions

View File

@@ -176,8 +176,9 @@ class FieldGetDbPrepValueMixin:
get_db_prep_lookup_value_is_iterable = False
def get_db_prep_lookup(self, value, connection):
# For relational fields, use the output_field of the 'field' attribute.
field = getattr(self.lhs.output_field, 'field', None)
# For relational fields, use the 'target_field' attribute of the
# output_field.
field = getattr(self.lhs.output_field, 'target_field', None)
get_db_prep_value = getattr(field, 'get_db_prep_value', None) or self.lhs.output_field.get_db_prep_value
return (
'%s',