PostGIS Adapter problem

80 views
Skip to first unread message

ubiquitousthey

unread,
Jan 25, 2011, 10:50:42 PM1/25/11
to geodjango
I posted this at the general Django group, and they pointed me here.

I am getting the following error when the queryset tries to generate
the SQL: "'str' object has no attribute 'ewkb'"

Here is what I am doing that causes the problem:
shapes = Shape.objects.filter(geom__bboverlaps=bbx)
shape_info = shape_info.filter(shape__in=shapes)

Models are:
class Shape(models.Model):

geom = models.PolygonField()
color = models.IntegerField()

class ShapeInfo(models.Model):

name = models.CharField(max_length=25)
shape = models.ForeignKey(Shape)

The code causing the problem seems to be:

if (len(params) == 1 and params[0] == '' and lookup_type ==
'exact'
and
connection.features.interprets_empty_strings_as_nulls):
lookup_type = 'isnull'
value_annot = True

Is this not an appropriate way to use this?

Here is the stacktrace:
/Library/Python/2.6/site-packages/django/db/models/query.py in
_result_iter
self._fill_cache() ...
▶ Local vars
/Library/Python/2.6/site-packages/django/db/models/query.py in
_fill_cache
self._result_cache.append(self._iter.next()) ...
▶ Local vars
/Library/Python/2.6/site-packages/django/db/models/query.py in
iterator
for row in compiler.results_iter(): ...
▶ Local vars
/Library/Python/2.6/site-packages/django/db/models/sql/compiler.py in
results_iter
for rows in self.execute_sql(MULTI): ...
▶ Local vars
/Library/Python/2.6/site-packages/django/db/models/sql/compiler.py in
execute_sql
sql, params = self.as_sql() ...
▶ Local vars
/Library/Python/2.6/site-packages/django/db/models/sql/compiler.py in
as_sql
where, w_params = self.query.where.as_sql(qn=qn,
connection=self.connection) ...
▶ Local vars
/Library/Python/2.6/site-packages/django/db/models/sql/where.py in
as_sql
sql, params = child.as_sql(qn=qn,
connection=connection) ...
▶ Local vars
/Library/Python/2.6/site-packages/django/db/models/sql/where.py in
as_sql
sql, params = self.make_atom(child, qn,
connection) ...
▶ Local vars
/Library/Python/2.6/site-packages/django/db/models/sql/where.py in
make_atom
if (len(params) == 1 and params[0] == '' and lookup_type ==
'exact' ...
▶ Local vars
/Library/Python/2.6/site-packages/django/contrib/gis/db/backends/
postgis/adapter.py in __eq__
return (self.ewkb == other.ewkb) and (self.srid ==
other.srid) ...
▼ Local vars
Variable Value
other
''
self
<django.contrib.gis.db.backends.postgis.adapter.PostGISAdapter object
at 0x10663bf90>

Justin Bronn

unread,
Jan 25, 2011, 11:58:41 PM1/25/11
to geod...@googlegroups.com
On 1/25/11 9:50 PM, ubiquitousthey wrote:
> Models are:
> class Shape(models.Model):
> …
> geom = models.PolygonField()
> color = models.IntegerField()
>
> class ShapeInfo(models.Model):
> …
> name = models.CharField(max_length=25)
> shape = models.ForeignKey(Shape)


On the `ShapeInfo` model do you have `objects = models.GeoManager` ?

See also:
http://docs.djangoproject.com/en/dev/ref/contrib/gis/model-api/#geomanager

-Justin

ubiquitousthey

unread,
Jan 27, 2011, 1:07:40 AM1/27/11
to geodjango
That did it. I didn't realize the ShapeInfo would need a GeoManager.
> See also:http://docs.djangoproject.com/en/dev/ref/contrib/gis/model-api/#geoma...
>
> -Justin
Reply all
Reply to author
Forward
0 new messages