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