#14922: Failure with spatial queries spanning a foreign key join
--------------------------+-------------------------------------------------
Reporter: crucialfelix | Owner: nobody
Status: new | Milestone:
Component: GIS | Version: 1.2
Keywords: | Stage: Unreviewed
Has_patch: 0 |
--------------------------+-------------------------------------------------
{{{
class Apt(Model):
geo = models.PointField(srid=4326,editable=False,default=Point(0,0))
class AptStatus(Model):
apt = models.ForeignKey(Apt)
from django.contrib.gis.geos import Polygon
box = Polygon.from_bbox(10,20,10,20)
AptStatus.objects.filter(apt__geo__within=box)
FieldError: Join on field 'geo' not permitted. Did you misspell 'within'
for the lookup type?
}}}
however I've found a nullable foreign key query did work:
{{{
class Apt(Model):
geo = models.PointField(srid=4326,editable=False,default=Point(0,0))
bldg = models.ForeignKey(Bldg,null=True)
class Bldg(Model):
geo = models.PointField(srid=4326,editable=False,default=Point(0,0))
Apt.objects.filter(bldg__geo__within=box)
SELECT ...
FROM "nsproperties_apt"
INNER JOIN "nsproperties_bldg" ON ("nsproperties_apt"."bldg_id" =
"nsproperties_bldg"."id")
WHERE ST_Within("nsproperties_bldg"."geo",
ST_GeomFromEWKB(E'\\001\\003\\000\\000
\\346\\020\\000\\000\\001\\000\\000\\000\\005\\000\\000\\000\\000\\000\\000\\000\\024\\333\\...@\\334\\302z\\310\\321\\177v\\300\\000\\000\\000\\000\\024\\333\\200@t"\\271,\\272\\177v\\300\\000\\000\\000\\0008\\230\\...@t"\\271,\\272\\177v\\300\\000\\000\\000\\0008\\230\\...@\\334\\302z\\310\\321\\177v\\300\\000\\000\\000\\000\\024\\333\\200@\\334\\302Z\\310\\321\\177V\\300'))LIMIT
21
}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/14922>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.