#29422: QuerySet.extra use case - "earth_box", "ll_to_earth"
-------------------------------------+-------------------------------------
Reporter: Mateusz | Owner: nobody
Kurowski |
Type: | Status: new
Cleanup/optimization |
Component: Database | Version: 2.0
layer (models, ORM) | Keywords: QuerySet.extra,
Severity: Normal | queryset, extra, earth_box,
| ll_to_earth, models, function,
Triage Stage: | expression, manager
Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
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?
--
Ticket URL: <https://code.djangoproject.com/ticket/29422>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/049.20cd8988f107e8d214d68834406cae89%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.