简体   繁体   中英

how to find the distance between 1 user and other users in django rest framework

i am making an app which tracks the users location when they login, when they search for other users in their area i want to be able to calculate the distance between the users location and other users and only display users who are in a certain mile radius which the user can choose. I would like to put it in a class based list api view as a filter but i don't know how to do it.

I have probably not explained it in the best way so please let me know if you don't understand my question

model would like user_1 current longitude and latitude

data_fields:

user_longitude = value
user_latitude = value

after fetching longitude and latitude. just another map API

In google map if you put longitude_value(38.7410' N) and latitude(44.5841' E) as your destination and also you current location as longitude_value(48.7410' N) and latitude(54.5841' E) you can find distance between two points

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM