﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
29422	"QuerySet.extra use case - ""earth_box"",  ""ll_to_earth"""	Mateusz Kurowski	nobody	"https://docs.djangoproject.com/en/2.0/ref/models/querysets/#extra

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?
"	Cleanup/optimization	closed	Database layer (models, ORM)	2.0	Normal	invalid	QuerySet.extra, queryset, extra, earth_box, ll_to_earth, models, function, expression, manager		Unreviewed	0	0	0	0	0	0
