jpk@truth:~/code/junkyard/geodjango_orm_bug$ ./manage.py shell_plus
From 'auth' autoload: Permission, Group, User, Message
From 'contenttypes' autoload: ContentType
From 'sessions' autoload: Session
From 'sites' autoload: Site
From 'myapp' autoload: Spot, Property
Python 2.7.2+ (default, Oct 4 2011, 20:06:09)
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> Spot.objects.all()
[<Spot: id: 1>, <Spot: id: 2>, <Spot: id: 3>, <Spot: id: 4>]
>>> Property.objects.all()
[<Property: belonging to Spot 1>, <Property: belonging to Spot 2>, <Property: belonging to Spot 3>, <Property: belonging to Spot 4>]
>>> spots = Spot.objects.all()
>>> props = Property.objects.filter(spot__in=spots)
>>> spots
[<Spot: id: 1>, <Spot: id: 2>, <Spot: id: 3>, <Spot: id: 4>]
>>> props
[<Property: belonging to Spot 1>, <Property: belonging to Spot 2>, <Property: belonging to Spot 3>, <Property: belonging to Spot 4>]
>>> for p in props:
... print p
...
belonging to Spot 1
belonging to Spot 2
belonging to Spot 3
belonging to Spot 4
>>> from django.contrib.gis.geos import Polygon
>>> northern_hemisphere = Polygon(( (-180,90),(180,90),(180,0),(-180,0),(-180,90) ))
>>> spots = Spot.objects.filter(location__contained=northern_hemisphere)
>>> spots
[<Spot: id: 1>, <Spot: id: 2>]
>>> props = Property.objects.filter(spot__in=spots)
>>> props
[]
>>> for p in props:
... print p
...
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/lib/pymodules/python2.7/django/db/models/query.py", line 107, in _result_iter
self._fill_cache()
File "/usr/lib/pymodules/python2.7/django/db/models/query.py", line 772, in _fill_cache
self._result_cache.append(self._iter.next())
File "/usr/lib/pymodules/python2.7/django/db/models/query.py", line 273, in iterator
for row in compiler.results_iter():
File "/usr/lib/pymodules/python2.7/django/db/models/sql/compiler.py", line 680, in results_iter
for rows in self.execute_sql(MULTI):
File "/usr/lib/pymodules/python2.7/django/db/models/sql/compiler.py", line 725, in execute_sql
sql, params = self.as_sql()
File "/usr/lib/pymodules/python2.7/django/db/models/sql/compiler.py", line 68, in as_sql
where, w_params = self.query.where.as_sql(qn=qn, connection=self.connection)
File "/usr/lib/pymodules/python2.7/django/db/models/sql/where.py", line 92, in as_sql
sql, params = child.as_sql(qn=qn, connection=connection)
File "/usr/lib/pymodules/python2.7/django/db/models/sql/where.py", line 95, in as_sql
sql, params = self.make_atom(child, qn, connection)
File "/usr/lib/pymodules/python2.7/django/contrib/gis/db/models/sql/where.py", line 50, in make_atom
return super(GeoWhereNode, self).make_atom(child, qn, connection)
File "/usr/lib/pymodules/python2.7/django/db/models/sql/where.py", line 166, in make_atom
if (len(params) == 1 and params[0] == '' and lookup_type == 'exact'
File "/usr/lib/pymodules/python2.7/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'
>>>