Django query order depending on starts_with and contains
I try to make a special contains filter in django such that,
- if items are cba, abc, abd etc.. and
- if I want to get 开发者_StackOverflow中文版the items that contains
ab,
the list should be ordered as abc,bca because abc starts with ab even though they both contains ab.
How can I make such query in django effectively ?
My query is at below
EmployerIndexed.objects.filter(name__icontains=empkw)
If I understand what you're asking, you want an alphabetical sort?
EmployerIndexed.objects.filter(name__icontains=empkw).order_by('name')
加载中,请稍侯......
精彩评论