[Django] #32380: GeoDjango lookups must be accept F() input

17 views
Skip to first unread message

Django

unread,
Jan 23, 2021, 9:42:11 AM1/23/21
to django-...@googlegroups.com
#32380: GeoDjango lookups must be accept F() input
----------------------------------------------+---------------------------
Reporter: mohammadhasanzadeh | Owner: nobody
Type: New feature | Status: new
Component: GIS | Version: 2.2
Severity: Normal | Keywords: geodjango
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
----------------------------------------------+---------------------------
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`.

--
Ticket URL: <https://code.djangoproject.com/ticket/32380>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 23, 2021, 9:44:46 AM1/23/21
to django-...@googlegroups.com
#32380: GeoDjango lookups must be accept F() input
------------------------------------+--------------------------------------

Reporter: mohammadhasanzadeh | Owner: nobody
Type: New feature | Status: new
Component: GIS | Version: 2.2
Severity: Normal | Resolution:

Keywords: geodjango | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------------+--------------------------------------
Description changed by mohammadhasanzadeh:

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>

Django

unread,
Jan 25, 2021, 1:48:06 AM1/25/21
to django-...@googlegroups.com
#32380: GeoDjango lookups should support F() expressions.
-------------------------------------+-------------------------------------
Reporter: Mohammad Hasanzadeh | Owner: nobody
Type: New feature | Status: closed
Component: GIS | Version: 3.0
Severity: Normal | Resolution: fixed

Keywords: geodjango | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* 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>

Django

unread,
Jan 25, 2021, 2:41:32 AM1/25/21
to django-...@googlegroups.com
#32380: GeoDjango lookups should support F() expressions.
-------------------------------------+-------------------------------------
Reporter: Mohammad Hasanzadeh | Owner: nobody
Type: New feature | Status: closed
Component: GIS | Version: 3.0
Severity: Normal | Resolution: fixed
Keywords: geodjango | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

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>

Reply all
Reply to author
Forward
0 new messages