SA
Skip to main content

Django Rest Framework Database Query Builder Does Not Stable Sort

A stupid bug on 2024-08-09 something that I expected so naturally that took me hours to find out.

I was expecting:

  • First = Second
  • Third = Fourth

209AF0.png

Think you're good at Django? Guess the answer!

C782E0.png

Which is not.

  • First = Second
  • Third ≠ Fourth

This really made me pull my hair off.

This is because Order By is not sorting itself, but rather a query builder. While I understand the reason behind it, I still think it's counterintuitive.