I'm having trouble constructing nested queries using in
field lookup in GeoDjango. The following code demonstrates the problem:
inner_qs = Footprint.objects.filter(geom__bboverlaps=bounding_box)
outer_qs = Footprint.objects.filter(pk__in=inner_qs)
outer_qs.count()
# error
With the above code, the follow exception occurs:
if (len(params) == 1 and params[0] == '' and lookup_type == 'exact'
File "../python2.6/site-packages/django/contrib/gis/db/backends/postgis/adapter.py", line 24, in __eq__
return (self.ewkb == other.ewkb) and (self.srid == other.srid)
AttributeError: 'str' object has no attribute 'ewkb'
(Here is the complete stack trace)
It appears that the error occurs whenever the inner query contains a spatial filter. The following nested query works fine though:
inner_qs = Footprint.objects.filter(frequency__gt=1)
outer_qs = Footprint.objects.filter(pk__in=inner_qs)
outer_qs.count()
# ok
Any idea what causes the problem?