Skip to content

Instantly share code, notes, and snippets.

View anchorcoding's full-sized avatar

AnchorCoding anchorcoding

  • AnchorCoding
  • Terneuzen, Netherlands
View GitHub Profile
@anchorcoding
anchorcoding / haversine.py
Created September 29, 2017 10:35 — forked from ncole458/haversine.py
Django Haversine Formula Queryset
"""
Find user/database entries within a km radius based on long/lat co-ords.
i.e. return all objects where longlat lies within 10km of my current long/lat.
Using with Django REST Framework but approach is same for any similar req.
"""
import math
def get_queryset(self):
user = self.request.user
lat = self.request.query_params.get('lat', None)