This is my use case:
{{{
#!div style="font-size: 80%"
Code highlighting:
{{{#!python
class City(models.Model):
longitude = models.FloatField(db_index=True)
latitude = models.FloatField(db_index=True)
# this works:
City.objects.extra(where=['earth_box(ll_to_earth(%s,%s), %s) @>
ll_to_earth(latitude, longitude)'], params=[51.41816, 15.90689, 500000])
# this does not:
City.objects.extra(where=['earth_box(ll_to_earth(%s,%s), %s) @>
ll_to_earth(latitude, longitude)'], params=[F('latitude'), F('longitude'),
50000])
# psycopg2.ProgrammingError: can't adapt type 'F'
}}}
}}}
I could rewrite this in a custom Manager, but how?
--
Ticket URL: <https://code.djangoproject.com/ticket/29422>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* resolution: => invalid
Comment:
Without going into too many details, I'd expect you to be able to define
two [https://docs.djangoproject.com/en/2.0/ref/models/expressions
/#writing-your-own-query-expressions user functions] (something like
`LLToBox()` taking two arguments and `LLToEarthBox()` taking three) and
use the builtin `contains` comparison, or, if this doesn't work, define
your own [https://docs.djangoproject.com/en/2.0/ref/models/lookups/
comparison].
In general, please direct such questions to the available help channels. I
am closing this ticket as invalid, for more details see
TicketClosingReasons/UseSupportChannels.
--
Ticket URL: <https://code.djangoproject.com/ticket/29422#comment:1>
Comment (by Mateusz Kurowski):
@Shai Berger how i can use **contains**? Can you show an example queryset,
how you see it?
--
Ticket URL: <https://code.djangoproject.com/ticket/29422#comment:2>