Refs #32380 -- Added test for distance lookups with F() expression.
Fixed in 5935a9aead
.
This commit is contained in:
parent
2b4b6c8af0
commit
84ad7f3404
|
@ -29,6 +29,7 @@ class AustraliaCity(NamedModel):
|
|||
point = models.PointField()
|
||||
radius = models.IntegerField(default=10000)
|
||||
allowed_distance = models.FloatField(default=0.5)
|
||||
ref_point = models.PointField(null=True)
|
||||
|
||||
|
||||
class CensusZipcode(NamedModel):
|
||||
|
|
|
@ -204,8 +204,10 @@ class DistanceTest(TestCase):
|
|||
# With spheroid param
|
||||
if connection.features.supports_distance_geodetic:
|
||||
hobart = AustraliaCity.objects.get(name='Hobart')
|
||||
AustraliaCity.objects.update(ref_point=hobart.point)
|
||||
for ref_point in [hobart.point, F('ref_point')]:
|
||||
qs = AustraliaCity.objects.filter(
|
||||
point__distance_lte=(hobart.point, F('radius') * 70, 'spheroid'),
|
||||
point__distance_lte=(ref_point, F('radius') * 70, 'spheroid'),
|
||||
).order_by('name')
|
||||
self.assertEqual(self.get_names(qs), ['Canberra', 'Hobart', 'Melbourne'])
|
||||
|
||||
|
|
Loading…
Reference in New Issue