我写过搜索视图。哪个工作得很好。现在我想改变一些逻辑。我想如果搜索“他”,结果应显示10个语言英语结果和10个语言法语结果。有什么建议吗?感谢
我正在尝试这样
languages = categories.language.all()
for language in languages:
m = Movie.objects.filter(title__istartswith=q, language=language)[:10]
答案 0 :(得分:1)
尝试:
results = []
for language in categories.language.all():
results.append(Movie.objects.filter(title__istartswith=q, language=language)[:10])