def get_prep_lookup(self, lookup_type, value):
        # Handling for `__len`, which is a custom lookup type
        # for arrays, must be properly handled.
        if lookup_type == 'len':
            try:
                return int(value)
            except ValueError:
                raise TypeError('__len only supports integers.')

        # Arrays do not support many built-in lookups.
        if lookup_type not in ('exact', 'contains'):
            raise TypeError('Unsupported lookup type: %s' % lookup_type)

        # If we're checking on a list, coerce each individual value into
        # its appropriate lookup type.
        if isinstance(value, (list, tuple)):
            value = [self.of.get_prep_lookup('exact', i) for i in value]

        # The superclass handling is good enough for everything else.
        return super(ArrayField, self).get_prep_lookup(lookup_type, value)
dataset/ETHPy150Open lukesneeringer/django-pgfields/django_pg/models/fields/array.py/ArrayField.get_prep_lookup/original