{{{
# Proposed
Model.objects.values(complex=SomeExpression()).aggregate(Sum('field'))
# Current
Model.objects.annotate(complex=SomeExpression()).values('complex').aggregate(Sum('field'))
}}}
The major hurdle here is allowing `**kwargs` into `values()` to support
the alias. That's an addition to the API so should be backwards
compatible, but it'll also probably rule out using various state based
kwargs like `flat=True` and their ilk in the future. We could do some
juggling to ensure we're only processing expression kwargs as expressions
by checking if they have the attribute `resolve_expression`.
--
Ticket URL: <https://code.djangoproject.com/ticket/25871>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* stage: Unreviewed => Accepted
Comment:
Related to "`QuerySet.values()` should be aliasable (#16735)" and
[https://groups.google.com/d/topic/django-
developers/m4lPPfFChNY/discussion django-developers discussion].
--
Ticket URL: <https://code.djangoproject.com/ticket/25871#comment:1>
* owner: nobody => Ian-Foote
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/25871#comment:2>
* has_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/25871#comment:3>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"39f35d4b9de223b72c67bb1d12e65669b4e1355b" 39f35d4b]:
{{{
#!CommitTicketReference repository=""
revision="39f35d4b9de223b72c67bb1d12e65669b4e1355b"
Fixed #25871 -- Added expressions support to QuerySet.values().
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/25871#comment:4>