Sort a Django Queryset by a Custom Order
At PixieBrix, we discovered sorting a Django queryset by a custom order can be challenging. Choosing the wrong solution for your use case can cripple your application's performance.
For example, letβs take a simple Todo model:
class Todo(models.Model):
class Priority(models.TextChoices):
HIGH = "HIGH&