我有一個位置數據點的表存儲在以下幾列:Django中使用的列值濾波
coordinates: the geolocation data in longitude and latitude
radius: the distance from coordinate that it is visible
現在我採取隨機點,並希望找到那些可見的隨機點點使用Django的地理位置,如:
LocationInfo.objects.filter(coordinates__distance_lt=(random_point, D(km=1))
目前我檢索方圓1公里內的點,但我想用半徑從表中。我如何使用表格中的半徑?
取代'公里= 1'與'公里= theVariableYouWant' –
我想用存儲在數據庫中 – sam23
半徑列中的值也爲我提供它的型號代碼,所以我可以告訴你代碼。您只需獲取'modelName.objects.get(id = yourDesiredId)'或取代其他任何您需要的ID來獲取它。希望這可以幫助! –