Integrations
/
Frameworks
/
Django
/
Geo-Search
May. 10, 2019
Geo-Search
Geo-Search
Use the geo_field
attribute to localize your record. geo_field
should be a callable that returns a tuple (latitude, longitude).
Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class Contact(models.model):
name = models.CharField(max_lenght=20)
lat = models.FloatField()
lng = models.FloatField()
def location(self):
return (self.lat, self.lng)
class ContactIndex(AlgoliaIndex):
fields = 'name'
geo_field = 'location'
algoliasearch.register(Contact, ContactIndex)
Did you find this page helpful?