Skip to content

Commit 92fc263

Browse files
committed
Fixed a regression in gis introduced by Query.select_fields removal
1 parent 0d8432d commit 92fc263

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

django/contrib/gis/db/models/query.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -760,8 +760,10 @@ def _geocol_select(self, geo_field, field_name):
760760
self.query.add_select_related([field_name])
761761
compiler = self.query.get_compiler(self.db)
762762
compiler.pre_sql_setup()
763-
rel_table, rel_col = self.query.related_select_cols[self.query.related_select_fields.index(geo_field)]
764-
return compiler._field_column(geo_field, rel_table)
763+
for (rel_table, rel_col), field in self.query.related_select_cols:
764+
if field == geo_field:
765+
return compiler._field_column(geo_field, rel_table)
766+
raise ValueError("%r not in self.query.related_select_cols" % geo_field)
765767
elif not geo_field in opts.local_fields:
766768
# This geographic field is inherited from another model, so we have to
767769
# use the db table for the _parent_ model instead.

0 commit comments

Comments
 (0)