

def process_rhs(self, compiler, connection):
    if ((not isinstance(self.rhs, (tuple, list))) or (not (2 <= len(self.rhs) <= 3))):
        raise ValueError(("2 or 3-element tuple required for '%s' lookup." % self.lookup_name))
    params = [connection.ops.Adapter(self.rhs[0])]
    dist_param = self.rhs[1]
    if hasattr(dist_param, 'resolve_expression'):
        dist_param = dist_param.resolve_expression(compiler.query)
        (sql, expr_params) = compiler.compile(dist_param)
        self.template_params['value'] = sql
        params.extend(expr_params)
    else:
        params += connection.ops.get_distance(self.lhs.output_field, ((dist_param,) + self.rhs[2:]), self.lookup_name, handle_spheroid=False)
    rhs = connection.ops.get_geom_placeholder(self.lhs.output_field, params[0], compiler)
    return (rhs, params)

dataset/ETHPy150Open django/django/django/contrib/gis/db/models/lookups.py DistanceLookupBase.process_rhs/original