Hi there -
I have two related models. MapUnitPolys has a 1:M relationship to
DescriptionOfMapUnits. MapUnitPolys has a geometry field,
DescriptionOfMapUnits does not.
The query that I'm trying to accomplish is something like
SELECT DISTINCT DescriptionOfMapUnits.*
FROM ( MapUnitPolys INNER JOIN DescriptionOfMapUnits ON
MapUnitPolys.MapUnit = DescriptionOfMapUnits.MapUnit )
WHERE MapUnitPolys.Shape Intersects <my masking polygon>
I can't quite figure out how to translate this into Django's Query API.
The closest I can come up with is two queries:
first_part = MapUnitPolys.objects.filter(Shape__intersects = <my masking
polygon>).values('MapUnit').Distinct
result_set = DescriptionOfMapUnits.objects.filter(MapUnit__in = first_part)
What is strange about this is that it works when the first query is
non-spatial. However, if I make the first query spatial, as shown above,
first_part is correctly populated, but result_set comes up empty. I
cannot for the life of me figure out why.
If anyone can see a better way to formulate that SQL query, or knows
what is going wrong with my two queries, let me know!
Thanks,
Ryan
--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.