﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
25499	Distance lookup not possible with a column value as distance	Bibhas C Debnath	Claude Paroz	"Right now this is possible - 

{{{
current_localities = Locality.objects.filter(centroid__distance_lte=(pnt, 1000))
}}}

which results in - 

{{{
(0.005) SELECT ""map_locality"".""id"", ""map_locality"".""name"", ""map_locality"".""slug"", ""map_locality"".""centroid"", ""map_locality"".""radius"" FROM ""map_locality"" WHERE ST_Distan
ce_Sphere(""map_locality"".""centroid"", ST_GeomFromEWKB('\x0101000020e6100000865ad3bce3685340e9b7af03e7ec2940'::bytea)) <= 1000 LIMIT 21;
}}}


But if I have a column named `radius` which has the radius for each Locality and `centroid` has the center point and I want to find all the localities that my current location falls in, I want to do something like this - 

{{{
current_localities = Locality.objects.filter(centroid__distance_lte=(pnt, F('radius')))
}}}

But it's not possible right now. It generates the error -

  ProgrammingError at /api/services/
  can't adapt type 'F'

But in reality, this is possible - 

{{{
SELECT ""map_locality"".""id"", ""map_locality"".""name"", ""map_locality"".""slug"", ""map_locality"".""centroid"", ""map_locality"".""radius"" FROM ""map_locality"" WHERE ST_Distance_Sphere(""map_locality"".""centroid"", ST_GeomFromEWKB('\x0101000020e6100000865ad3bce3685340e9b7af03e7ec2940'::bytea)) <= radius*1000 LIMIT 21;
}}}

Here I'm using `radius*1000` as the result of `ST_Distance_Sphere()` is in meter and my radius value is in km. I'm looking for suggestions on how to handle cases like this in the ORM, but I do think that the support for using a column value using `F()` would be *really* helpful."	New feature	closed	GIS	dev	Normal	fixed	1.10	Jani Tiainen	Accepted	0	0	0	0	0	0
