Which Model Field to use in Django to store longitude and latitude values?

前端 未结 3 1906
小鲜肉
小鲜肉 2021-02-02 05:09

I want to store my users location using longitude and latitude, at the moment this comes from Google Maps, but I will be using GeoDango and some point to work out distances betw

3条回答
  •  梦毁少年i
    2021-02-02 05:48

    Use PointField to store lat long

    p = Point(85.3240, 27.7172,srid=4326)
    

    Django: 1.X:

    https://docs.djangoproject.com/en/1.11/ref/contrib/gis/model-api/#pointfield

    Django: 2.X:

    https://docs.djangoproject.com/en/2.2/ref/contrib/gis/model-api/#pointfield

    Django: 3.X: https://docs.djangoproject.com/en/3.0/ref/contrib/gis/model-api/#pointfield

提交回复
热议问题