'Prepare for the database lookup, and return any spatial parameters
necessary for the query.  This includes wrapping any geometry
parameters with a backend-specific adapter and formatting any distance
parameters into the correct units for the coordinate system of the
field.'

def get_db_prep_lookup(self, lookup_type, value, connection, prepared=False):

    if (lookup_type in connection.ops.gis_terms):
        if (lookup_type == 'isnull'):
            return []
        if isinstance(value, (tuple, list)):
            params = [connection.ops.Adapter(value[0])]
            if (lookup_type in connection.ops.distance_functions):
                params += self.get_distance(value[1:], lookup_type, connection)
            elif (lookup_type in connection.ops.truncate_params):
                pass
            else:
                params += value[1:]
        elif isinstance(value, SQLEvaluator):
            params = []
        else:
            params = [connection.ops.Adapter(value)]
        return params
    else:
        raise ValueError(('%s    is    not    a    valid    spatial    lookup    for    %s.' % (lookup_type, self.__class__.__name__)))
