【发布时间】:2010-12-16 12:04:36
【问题描述】:
我正在做标签搜索功能,用户可以观察到很多标签,我把它全部放在一个元组中,现在我想从列表中找到至少包含一个标签的所有文本。
象征性:text__contains__in=('asd','dsa')
我唯一的想法是循环,例如:
q = text.objects.all()
for t in tag_tuple:
q.filter(data__contains=t)
例如:
输入标签元组,('car', 'cat', 'cinema')
输出包含该元组中至少一个单词的所有消息,所以 My cat is in the car , cat is not allowed in the cinema , i will drive my car to the cinema
感谢您的帮助!
【问题讨论】:
-
你能举一个输入和预期输出的例子吗?
标签: django django-queryset django-orm