#27021: Add explicit support for Q object annotations
-------------------------------------+-------------------------------------
Reporter: Josh Smeaton | Owner: (none)
Type: New feature | Status: new
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 1
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Ian Foote):
While working on #470, I've created a proof of concept implementation that
allows annotating lookups without requiring a {{{Q}}} object. (See
https://github.com/django/django/commit/d67c858198903839b6b5bf15e04cbf7a7072190e.)
Instead of {{{Model.objects.annotate(boolfield=Q(field__gte=4))}}}, we
would instead write something like
{{{Model.objects.annotate(boolfield=F('field') >= 4)}}}.
This is more flexible than the original proposal here because it allows
comparing expressions other than fields. For example:
{{{Model.objects.annotate(boolfield=Random() > 0.5)}}}.
If this proposed API is accepted, I'll assign this ticket to myself again
and polish up my proof of concept.
--
Ticket URL: <https://code.djangoproject.com/ticket/27021#comment:10>
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 view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/066.b7d880c22466948c067415c478eeb0ed%40djangoproject.com.