LIKE query in Django ORM

╄→尐↘猪︶ㄣ 提交于 2019-12-12 06:39:13

问题


How can I make query, with rule: order by words, that contain founded string as close as possible to the beginning. Is it real?

For example:
search 'hi'
result:
hi all
hi cat
Peter, hi
I come to you and say hi

query = query & Q(name__contains=params['name'])

回答1:


SearchRank is the answer to your question, hope you are using django with postgreSQL, I will not explain as it is well explained in the django docs. Here is the link to it:- Django SearchRank

Enjoy and rejoice :-)



来源:https://stackoverflow.com/questions/46221508/like-query-in-django-orm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!