Skip to content

Instantly share code, notes, and snippets.

View mehrabcz's full-sized avatar

mehrab mehrabcz

  • Tehran,IR
View GitHub Profile
@mehrabcz
mehrabcz / distance.py
Created March 8, 2023 10:11 — forked from ncole458/distance.py
Django queryset for objects within X long/lat radius
# Simple version of Django queryset for objects within X long/lat radius
import math
def get_queryset(self):
user = self.request.user
lat = self.request.query_params.get('lat', None)
lon = self.request.query_params.get('long', None)
if lat and lon:
lat = float(lat)