Skip to content

Instantly share code, notes, and snippets.

@octaflop
Last active August 29, 2015 14:24
Show Gist options
  • Save octaflop/bd12efa339af52b56ae4 to your computer and use it in GitHub Desktop.
Save octaflop/bd12efa339af52b56ae4 to your computer and use it in GitHub Desktop.
from django.contrib.gis.measure import D
from django.contrib.gis.geos import Point
SRID = 4326
pnt = Point(lat, lon, srid=SRID)
class Location(models.Model):
point = models.PointField()
objects = models.GeoManager()
campuses = Location.objects.filter(
point__distance_lte=(pnt, D(mi=1)))
# raises: "distance_lte is not a valid spatial lookup for PointField"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment