Fixed a regression in gis introduced by Query.select_fields removal

This commit is contained in:
Anssi Kääriäinen 2012-11-02 14:54:50 +02:00
parent 0d8432da55
commit 92fc263a28
1 changed files with 4 additions and 2 deletions

View File

@ -760,8 +760,10 @@ class GeoQuerySet(QuerySet):
self.query.add_select_related([field_name])
compiler = self.query.get_compiler(self.db)
compiler.pre_sql_setup()
rel_table, rel_col = self.query.related_select_cols[self.query.related_select_fields.index(geo_field)]
return compiler._field_column(geo_field, rel_table)
for (rel_table, rel_col), field in self.query.related_select_cols:
if field == geo_field:
return compiler._field_column(geo_field, rel_table)
raise ValueError("%r not in self.query.related_select_cols" % geo_field)
elif not geo_field in opts.local_fields:
# This geographic field is inherited from another model, so we have to
# use the db table for the _parent_ model instead.