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

前端 未结 3 1904
小鲜肉
小鲜肉 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条回答
  •  清酒与你
    2021-02-02 05:23

    Float is generally an approximation, see here for some simple examples. You could get very nice results modifying your model to something like DecimalField(max_digits=9, decimal_places=6), since decimals are very important in coordinates but using more than 6 is basically meaningless.

    edit: a cute and in-topic XKCD strip to celebrate my first 100 votes!

提交回复
热议问题