Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django and keeping coordinates

What would be the ideal way of keeping location coordinates as a model field inorder to use at Google Maps at Django?

like image 849
Hellnar Avatar asked Jun 14 '11 14:06

Hellnar


2 Answers

Here's the code I use for storing Google's Lat/Lon

lat = models.FloatField(_('Latitude'), blank=True, null=True)
lon = models.FloatField(_('Longitude'), blank=True, null=True)
like image 192
silent1mezzo Avatar answered Oct 22 '22 09:10

silent1mezzo


Possible a better idea is to store in decimal field

lat = models.DecimalField(_('Latitude'), max_digits=10, decimal_places=8)
lng = models.DecimalField(_('Longitude'), max_digits=11, decimal_places=8)

see https://stackoverflow.com/a/12504340/1977197

like image 35
Sergey Telminov Avatar answered Oct 22 '22 07:10

Sergey Telminov