* ui_ux: => 0
* type: => Uncategorized
* severity: => Normal
* easy: => 0
Comment:
See http://stackoverflow.com/a/35494930/15690, which uses a specilaized
QuerySet/Query.
The ``extra()`` approach is deprecated, and won't work with foreign keys /
joined tables.
--
Ticket URL: <https://code.djangoproject.com/ticket/13312#comment:5>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: closed => new
* resolution: wontfix =>
Comment:
Now that we have expressions, I think it's fine to reopen this ticket. We
can introduce a `OrderNulls.last()/.first()` expression to handle this in
a standard way. We could also just build it right into the `OrderBy`
expression:
{{{
qs.order_by(F('my_field').asc().nullslast())
}}}
If we do build this into the existing order_by, you'll need to be careful
about preserving a 'feature' that stops django from inserting duplicate
ordering clauses (it builds each component then does a string compare to
ensure the new clause isn't a duplicate).
This won't normalise order by nulls across backends, but it'll allow users
to control null handling semantics if they have a use for it. NULL
handling was originally going to be added to the OrderBy expression, but I
ran out of time before that could happen.
--
Ticket URL: <https://code.djangoproject.com/ticket/13312#comment:6>