Since your UserProfile
contains more than one geographic field, you should specify the one you want with the field_name
argument to distance()
.
UserProfile.objects.exclude(user=user).filter(current_location__distance_lte=(origin, D(mi=distance_mi))).distance(origin, field_name='current_location').order_by('distance')[:20]
See the documentation for more details.