{{{
return
queryset.filter(checkin_position__distance_gte=(F("doctor_location__location__position"),
D(km=200)) )
}}}
We will get the following error:
`ValueError: Cannot use object with type F for a spatial lookup
parameter.`
Note that `doctor_location__location__position` is a `PointField`.
--
Ticket URL: <https://code.djangoproject.com/ticket/32380>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Old description:
> For example, if we need to calculate the distance between two model field
> with the `distance_gte` lookup like the following:
>
> {{{
> return
> queryset.filter(checkin_position__distance_gte=(F("doctor_location__location__position"),
> D(km=200)) )
> }}}
>
> We will get the following error:
> `ValueError: Cannot use object with type F for a spatial lookup
> parameter.`
>
> Note that `doctor_location__location__position` is a `PointField`.
New description:
For example, if we need to calculate the distance between two field of the
model with the `distance_gte` lookup like the following:
{{{
return
queryset.filter(checkin_position__distance_gte=(F("doctor_location__location__position"),
D(km=200)) )
}}}
We will get the following error:
`ValueError: Cannot use object with type F for a spatial lookup
parameter.`
Note that `doctor_location__location__position` is a `PointField`.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/32380#comment:1>
* cc: Simon Charette (added)
* status: new => closed
* version: 2.2 => 3.0
* resolution: => fixed
Comment:
This was fixed in 5935a9aeade517aebdceea989467d2b46c44d96f (Django 3.0). I
sent [https://github.com/django/django/pull/13931 PR] with extra tests.
--
Ticket URL: <https://code.djangoproject.com/ticket/32380#comment:2>
Comment (by GitHub <noreply@…>):
In [changeset:"84ad7f34043c112a932b3ea396ebc98717bfd7e7" 84ad7f34]:
{{{
#!CommitTicketReference repository=""
revision="84ad7f34043c112a932b3ea396ebc98717bfd7e7"
Refs #32380 -- Added test for distance lookups with F() expression.
Fixed in 5935a9aeade517aebdceea989467d2b46c44d96f.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32380#comment:3>