⬅︎ Back to How to sort case insensitively with empty strings last in Django
Great solution. Thank you for posting this. I also needed to have German umlauts in their natural order (i.e. `ä` before `b` and not after `z`) so I ended up with this:Model.objects.order_by(Collate(Lower(NullIf("my_field", Value(""))), "de-x-icu"))
Comment
Great solution. Thank you for posting this.
I also needed to have German umlauts in their natural order (i.e. `ä` before `b` and not after `z`) so I ended up with this:
Model.objects.order_by(Collate(Lower(NullIf("my_field", Value(""))), "de-x-icu"))