Opened 7 years ago

Closed 7 years ago

#28006 closed New feature (fixed)

allow D to be used with lookups on Distance annotation

Reported by: Sergey Fedoseev Owned by: Sergey Fedoseev
Component: GIS Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

In [2]: from django.contrib.gis.db.models.functions import Distance
In [6]: City.objects.annotate(d=Distance('point', Point(2, 3, srid=4326))).values_list('d', flat=True).first()
Out[6]: Distance(m=247555.57168135)
In [7]: from django.contrib.gis.measure import D
In [10]: City.objects.annotate(d=Distance('point', Point(2, 3, srid=4326))).values_list('d', flat=True).filter(d=D(m=247555.57168135)).first()
...
TypeError: float() argument must be a string or a number, not 'Distance'

Change History (5)

comment:1 by Sergey Fedoseev, 7 years ago

Owner: changed from nobody to Sergey Fedoseev
Status: newassigned

comment:2 by Claude Paroz, 7 years ago

Triage Stage: UnreviewedAccepted

comment:3 by Sergey Fedoseev, 7 years ago

comment:4 by Sergey Fedoseev, 7 years ago

Has patch: set

comment:5 by Tim Graham <timograham@…>, 7 years ago

Resolution: fixed
Status: assignedclosed

In fd892f34:

Fixed #28006 -- Allowed using D with lookups on Distance annotations.

Note: See TracTickets for help on using tickets.
Back to Top