1👍
You can use extra:
q = Entry.objects.extra(select={'my_sort_field':
"some think like ___
FIND_IN_SET( left(somefield,1),'c,a,d,b') "})
q = q.extra(order_by = ['my_sort_field'])
But, if was this my model, I will create a new field intended for sort operations and I will keep it overwriting save() method or by signals.
- [Answered ]-How can I delete the '0' from my date day in django (python)?
- [Answered ]-Django: TypeError: 'x' is an invalid keyword argument for this function
Source:stackexchange.com