[Django]-GeoDjango distance query for a ForeignKey Relationship

5👍

For the first one, you will need to change it to:

modelB.objects.all().distance(loc, field_name='modela__point')

if you want to see all modelB objects.

The “.distance” is used to calculate and add a distance field to each resulting row of the QuerySet (or GeoQuerySet).

Leave a comment