[Answer]-GeoDjango distance query ForeignKey

1👍

Try this:

TestUsers.objects.filter(location__geoCoords__distance_lt=(address1, D(mi=23)))

0👍

Needed to add following to the model that is using Address as a ForeignKey

objects = models.GeoManager() 

Once that is done, the following query resolves properly:

TestUsers.objects.filter(location__geoCoords__distance_lte=(caddr.geoCoords, D(mi=21)))
👤trex

Leave a comment