On Wednesday, 11 June 2014 12:28:20 UTC+1, Josh Smeaton wrote: > > > Model.objects.filter(...).order_by( F('fld_a').desc(), > F('fld_b')).asc() ) > > Model.objects.filter(...).order_by( (F('fld_a')+F('fld_b')).desc() ) > > I actually really like this. It's simple, clear, and gets around the > issues being discussed. It still requires Expressions to know about > ordering (to implement the asc/desc methods) but I think that's fine. > > The other problem with having ordering objects being of a different type > means that you would have to call asc or desc. But now I think of it, the > order_by method could just call asc, by default, on any expressions passed > in. >
I agree, this looks like a good API and fixes a lot of my concerns. I've got this implemented in my branch now (https://github.com/timmartin/django/tree/order_by_expressions) Other than some small bits of tidying, I think the only thing missing here is documentation and a bunch of instances of expressions.Func() for the SQL functions we want to support. Josh, what's the likely timeline of getting your branch merged in? And will your change include any function definitions, or shall I do that as part of my work? Tim -- You received this message because you are subscribed to the Google Groups "Django developers" 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 http://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/cd9b72a3-a86f-4560-9a73-6e2849742c83%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.