Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#32380 closed New feature (fixed)

GeoDjango lookups should support F() expressions.

Reported by: Mohammad Hasanzadeh Owned by: nobody
Component: GIS Version: 3.0
Severity: Normal Keywords: geodjango
Cc: Simon Charette Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Mohammad Hasanzadeh)

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.

Change History (3)

comment:1 by Mohammad Hasanzadeh, 3 years ago

Description: modified (diff)

comment:2 by Mariusz Felisiak, 3 years ago

Cc: Simon Charette added
Resolution: fixed
Status: newclosed
Summary: GeoDjango lookups must be accept F() inputGeoDjango lookups should support F() expressions.
Version: 2.23.0

This was fixed in 5935a9aeade517aebdceea989467d2b46c44d96f (Django 3.0). I sent PR with extra tests.

comment:3 by GitHub <noreply@…>, 3 years ago

In 84ad7f34:

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

Fixed in 5935a9aeade517aebdceea989467d2b46c44d96f.

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