Closed vitosamson closed 7 months ago
Yes. I actually am planning on redoing the ordering functionality because the current one has a lot of issues. For example, there's no way for you to ask for 2 or more ordering in a given sequence, since the sequence used will be the ones defined by the attributes.
Together with that I also want to make it possible to have custom orderings, just like filters.
@bellini666
Thank you for considering nulls_last ordering also!
wo = Work_Order.objects.order_by(F('dateWORequired').asc(nulls_last=True))
Feature Request Type
Description
I'm wondering if you'd consider supporting custom methods on
ordering.order
classes, in the same way you do forfilters.filter
classes. Something like:This would be really useful when you want to order by some related model, but don't necessarily want to expose that relation and expect the client to know about it. In the example above, we're exposing
related_thing__name
asrelated_thing
without leaking the db architecture details. It's also really handy if you need to annotate the queryset before ordering on it, e.g. for things like computed time deltas (days_in_progress
and such).I'm currently doing the following to implement this, but it only works in custom resolvers and not when the order class is passed to either the type or the field definition:
Upvote & Fund