1 from forum.models import Question
3 def question_search(keywords):
4 return Question.objects.extra(
6 'ranking': "ts_rank_cd(tsv, plainto_tsquery(%s), 32)",
8 where=["tsv @@ plainto_tsquery(%s)"],
10 select_params=[keywords]
11 ).order_by('-ranking')