Hi --

I'm trying to figure out how to do a geospatial query that references a model field in the filter.
class Article(geomodels.Model):
    point = PointField(...)
    radius = IntegerField(...)

query_point = Point (...)

Articles.objects.filter(point__distance_lt=(query_point, F('radius')))

I tried using the F() object, but, not surprisingly, it did not work.
Has anyone figured out how to do this?
Perhaps there's some workaround using extra()?

Liam

Someone else had this question, elsewhere, but it went unanswered...
I have a model (let's call it A) that has a point field  and a radius
field:

class A(geomodels.Model):
    point = geomodels.PointField(srid=<srid>)
    radius = models.PositiveIntegerField()

How do I make a query that yields all A objects for which a given
point's distance from the object's point is within the object's
radius?

My first thought was to use the F() method to reference the radius
field on the A model:

query_point = <some point object>
a_qs = A.objects.filter(point__distance_lte=(query_point,
D(mi=F('radius')))

This, of course, does not work.

Any suggestions?


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to