class FieldGetDbPrepValueMixin
from django.db.models.lookups import FieldGetDbPrepValueMixin
Some lookups require Field.get_db_prep_value() to be called on their inputs.
Ancestors (MRO)
- builtins.object
- django.db.models.lookups.FieldGetDbPrepValueMixin
Attribute | Value | Defined in |
---|---|---|
get_db_prep_lookup_value_is_iterable |
False |
django.db.models.lookups.FieldGetDbPrepValueMixin |
def get_db_prep_lookup(self, value, connection)
django.db.models.lookups.FieldGetDbPrepValueMixin
def get_db_prep_lookup(self, value, connection):
# 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",
(
[get_db_prep_value(v, connection, prepared=True) for v in value]
if self.get_db_prep_lookup_value_is_iterable
else [get_db_prep_value(value, connection, prepared=True)]
),
)