[Answered ]-Django: order QuerySet by whether a field value is in a list

2👍

my_qs = MyModel.objects.filter(id__in=[1,3,5,11])
not_my_qs = MyModel.objects.exclude(id__in=[1,3,5,11])

from itertools import chain
result_list = list(chain(my_qs, not_my_qs))

Leave a comment