Fixed #27014 -- Fixed annotations with database functions on PostGIS.

Thanks Sean Mc Allister for providing a test.
This commit is contained in:
Daniel Wiesmann 2016-08-15 18:18:48 +01:00 committed by Tim Graham
parent 48ede58971
commit 89f17e7caf
3 changed files with 7 additions and 1 deletions

View File

@ -15,7 +15,7 @@ class PostGISAdapter(object):
"""
Initialize on the spatial object.
"""
self.is_geometry = isinstance(obj, Geometry)
self.is_geometry = isinstance(obj, (Geometry, PostGISAdapter))
# Getting the WKB (in string form, to allow easy pickling of
# the adaptor) and the SRID from the geometry or raster.

View File

@ -48,3 +48,6 @@ Bugfixes
* Fixed ``ClearableFileInput`` to avoid the ``required`` HTML attribute when
initial data exists (:ticket:`27037`).
* Fixed annotations with database functions when combined with lookups on
PostGIS (:ticket:`27014`).

View File

@ -142,6 +142,9 @@ class GeographyFunctionTests(TestCase):
qs = Zipcode.objects.annotate(distance=Distance('poly', htown.point))
for z, ref in zip(qs, ref_dists):
self.assertAlmostEqual(z.distance.m, ref, 2)
# Distance function in combination with a lookup.
hzip = Zipcode.objects.get(code='77002')
self.assertEqual(qs.get(distance__lte=0), hzip)
@skipUnlessDBFeature("has_Area_function", "supports_distance_geodetic")
def test_geography_area(self):