0

So I'm building Django app which has some stores saved with coordinates in db, all I need to do, when I get user coordinates, I want to search in db for the nearest store, IDk what to do after receiving coordinates eveything raises error

tried this hard coded query lookup

Shop.objects.filter(location__dwithin  = (GEOSGeometry(Point(-95.23592948913574, 38.97127105172941)), D(km=5)))

but still getting errors like

Only numeric values of degree units are allowed on geographic DWithin queries.

the srid if it matters is 4326, idk even know what this is

mohamed naser
  • 359
  • 3
  • 9
  • Pedantic note: do you really that precision? With this coordinates you're entering the microscopy realm `-95.23592948913574` ;) – Jim Jones Jul 27 '22 at 15:37
  • idk, it's just random coordinates from the internet :"D – mohamed naser Jul 27 '22 at 16:58
  • There is an answer to your issue: https://stackoverflow.com/questions/57137122/geodjango-finding-objects-in-radius/57270114#57270114 "For geographic geometries, you should use units of the geometry field (e.g. degrees for WGS84)" – John Moutafis Oct 05 '22 at 10:20

0 Answers0