2

我在使用GeoDjango中的in字段查找构建嵌套查询时遇到问题。下面的代码演示了这个问题:

inner_qs = Footprint.objects.filter(geom__bboverlaps=bounding_box)
outer_qs = Footprint.objects.filter(pk__in=inner_qs)
outer_qs.count()
# error

使用上面的代码,会发生以下异常:

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'

(这是完整的堆栈跟踪

只要内部查询包含空间过滤器,就会出现错误。以下嵌套查询可以正常工作:

inner_qs = Footprint.objects.filter(frequency__gt=1)
outer_qs = Footprint.objects.filter(pk__in=inner_qs)
outer_qs.count()
# ok

知道是什么导致了问题吗?

4

0 回答 0