There is a problem with the request for the GIS request, the request returns a list of elements that have coordinates outside the area in which I searched, what happens?
from django.contrib.gis.geos import Polygon from deals.models import Deal x1, y1 = 37.446899, 55.693455 x2, y2 = 37.666626, 55.551165 area = Polygon(((x1, y1), (x2, y1), (x2, y2), (x1, y2), (x1, y1))) qs = Deal.objects.filter(locations__coords__coveredby=area) def count(): ok, failed = 0, 0 for item in qs.filter(locations__coords__isnull=False)[:20]: for loc in item.locations.all(): lon = loc.longitude lat = loc.latitude if x1 <= lon <= x2 and y1 <= lat <= y2: ok += 1 else: failed += 1 return ok, failed >>> ok, failed Out[18]: (0, 11)
source share