id,summary,reporter,owner,description,type,status,component,version,severity,resolution,keywords,cc,stage,has_patch,needs_docs,needs_tests,needs_better_patch,easy,ui_ux 22352,GeoQuerySet methods: support lookups on reversed o2o relationships as field_name,pchiquet,anonymous,"GeoQuerySet methods, for example ''distance'', are performed on a given geographic field of the model. The geographic field to use can be specified thanks the '''field_name''' argument. '''field_name''' can be a field directly in the model or a lookup to a related field in another model (such as, {{{'address__point'}}}). However '''lookups with reversed one to one relation are not supported'''. For example, with the following model: {{{ #!python class User(Model): pass class UserProfile(NamedModel): user = models.OneToOneField(User) point = models.PointField() }}} the following spatial operation on User fails: {{{ #!python User.objects.all().distance(Point(1,1), field_name='userlocation__point') }}} and raises the following exception: {{{ Traceback (most recent call last): (...) File ""django/contrib/gis/db/models/query.py"", line 104, in distance return self._distance_attribute('distance', geom, **kwargs) File ""django/contrib/gis/db/models/query.py"", line 593, in _distance_attribute procedure_args, geo_field = self._spatial_setup(func, field_name=kwargs.get('field_name', None)) File ""django/contrib/gis/db/models/query.py"", line 466, in _spatial_setup raise TypeError('%s output only available on GeometryFields.' % func) TypeError: ST_Distance output only available on GeometryFields. }}} The lookup is supported only if the foreign key is in the Queryset model. I think it would be nice to support reversed relations too.",New feature,closed,GIS,dev,Normal,wontfix,"geodjango, GeoQuerySet",mmitar@… jernej@…,Accepted,1,0,0,1,0,0