rudra
rudra

Reputation: 71

python django latitude longitude filter in queryset

I have a field like

class MyModel(models.Model):
    latitude = models.CharField(max_length=100, db_index=True)
    longitude = models.CharField(max_length=100, db_index=True)

Lets say I have lat long value like

myval = (27.66469717424158, 85.30983049711507)

Here I want to find all the objects in MyModel which are less than 10 KM in distance from myval

I looked into geopy library. I think it is useful after I get the data from queryset.

How to achieve this ?

Upvotes: 1

Views: 211

Answers (1)

Yurii
Yurii

Reputation: 56

I think the best way to doing this using Django is GeoDjango. However, if you using ElasticSearch it can be done even easier, just link geo point to your Document class.

Upvotes: 0

Related Questions