mardi 5 mai 2015

Django Rest Framework - How do I limit results returned with Geolocation?

I have a model which stores a users location:

[
{
    "url": "http://ift.tt/1GNHAVn",
    "id": 1,
    "owner": 1,
    "test_info": "",
    "created_at": "2015-05-02T07:09:16.535689Z",
    "updated_at": "2015-05-02T07:09:16.535746Z",
    "geolocation": null,
    "jukebox_mode_enabled": false
},
{
    "url": "http://ift.tt/1GZuZ78",
    "id": 2,
    "owner": 2,
    "test_info": "",
    "created_at": "2015-05-02T07:09:24.206959Z",
    "updated_at": "2015-05-02T07:09:24.207042Z",
    "geolocation": null,
    "jukebox_mode_enabled": false
},

I am trying to achieve a system that allows users to query and see who else is nearby but for security reasons I would like to limit the results to users with say 1KM.

What is the best way to achieve this?

P.S - The "status" is tied to the normal user model in the django model using a oneToOneField.

Aucun commentaire:

Enregistrer un commentaire