Refs #32380 -- Added test for distance lookups with F() expression.

Fixed in 5935a9aead.
This commit is contained in:
Mariusz Felisiak 2021-01-25 08:40:46 +01:00 committed by GitHub
parent 2b4b6c8af0
commit 84ad7f3404
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View File

@ -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):

View File

@ -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'])