On Saturday, November 26, 2016 at 1:51:05 AM UTC+1, Josh Smeaton wrote:
>
> OrderBy takes an expression - it doesn't have to be a single column. For 
> example, this is valid:
>
> (Lower('last_name') + Lower('first_name)).desc() == 
> OrderBy(Lower('last_name') + Lower('first_name), descending=True)
>

Yes. However, I was more interested in being able to add a list of 
expressions. The OrderBy-class does not evaluate more than
one expression. The Case-expression right above iterates over all of the 
cases, and parses them. This is what I had in mind. I don't writing 
something for it, but
I'm trying to use as much of the existing API as possible.

What I had in mind was offering the flexibility to write this (maybe 
offering a list of OrderBy-clauses as valid input would be a way to 
remediate this):

I read over the Query-class code which has add_ordering.

qs = WindowTestModel.objects.annotate(sum=Window(
    expression=Sum('salary'),
    order_by=[ExtractYear('hiredate'), F('department')])
)
print(qs.query)

Kind regards,

Mads

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/5aecd2cc-452c-43df-a0eb-b482220839eb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to