python - How to make a quick db select of the range of latitude and longitude in Django? -
there table:
class place(models.model): user = models.manytomanyfield(settings.auth_user_model, related_name='places_user') title = models.charfield(max_length=250) address = models.charfield(max_length=500) latitude = models.floatfield() longitude = models.floatfield() image = models.imagefield(upload_to='place-images') def __unicode__(self): return self.title
please tell me how make quick select of range of latitudes , longitudes.
for example, there 100,000 records. need choose records in longitude 101.25..117.39 , latitude 223.46..232.55.
i think use postgres database.
in result think use postgis + geodjango. details: geodjango blog page.
use range query:
place.objects.filter( longitude__range=(101.25, 117.39), latitude__range=(223.46, 232.55), )
Comments
Post a Comment