I have a Django model with the following field:
class PropertyPost(models.Model): ... location=models.PointField(null=True,blank=True) ...
I am filtering the objects.locations in PgAdmin against a user provided polygon then I would have only points in the polygon as follows:
select propertypost_propertypost.* From propertypost_propertypost where st_contains( St_SetSRID( 'POLYGON((1616523 -172630,1618559 -170395,1612691 -169037,1610057 -170554,1609857 -175464,1611294 -176382,1616523 -172630))'::geometry, 3857), propertypost_propertypost.location)
this gives me 3 outputs as the result. Then in my django app I use the following view to do the same filtering:
class PropertyPostList(generics.ListCreateAPIView): ... def get_queryset(self): polystr = self.request.query_params.get('poly', None) if polystr: poly = GEOSGeometry('SRID=4326;' + polystr) qs = PropertyPost.objects.filter(location__contained=poly) return qs
now when I pass the following request it returns 4 results, which include the previous 3 results plus one more:
I was wondering why this two different query gives different results, are they actually different?