对于一个圣经网站,我可以搜索像《创世纪》这本书的所有诗句,或是“创世纪1”一章,但当我搜索像《创世纪1:1》这样的诗句时,就会出错
我怎样才能把1:1分开,这样我也能找到经文
def get_queryset(self):
query = self.request.GET.get('q')
object_list = Verse.objects.all()
if query:
query = query.split()
book = query[0]
object_list = object_list.filter(book__icontains=book)
if len(query) > 1:
chapter = query[1]
object_list = object_list.filter(chapter=chapter)
return object_list
为章节筛选后添加此项
相关问题 更多 >
编程相关推荐