Can Django ORM do an ORDER BY on a specific value of a column?

For those in need just like me that stumbled on this now and are using newer versions of django

Ticket.objects.annotate(
            relevancy=Case(When(status=4, then=1), When(status=3, then=2), When(status=2, then=3), output_field=IntegerField())
        ).order_by('-relevancy')

Using Count() will return 1 or 0 depending if your case was found or not. Not ideal if ordering by a couple of status


q = Ticket.objects.extra(select={'is_top': "status = 4"})
q = q.extra(order_by = ['-is_top'])

I did this while using PostgresSql with django.

from django.db.models import Case, Count, When

Ticket.objects.annotate(
    relevancy=Count(Case(When(status=4, then=1)))
).order_by('-relevancy')

It will return all objects from Ticket, but tickets with status = 4 will be at the beginning.

Hope someone will find it useful.