Django:icontains大小写对Unicode敏感

Hra*_*yan 0 python django unicode search-engine django-models

我正在对我的博客进行简单搜索。我使用亚美尼亚语,搜索时对这些字母总是很敏感。这是我的代码的一部分。先感谢您。

search_query = get.get('search')
query_list = search_query.split()
posts = post.objects.filter(
                reduce(operator.and_,
                       (Q(title__icontains=q) for q in query_list))|
                reduce(operator.and_,
                       (Q(content__icontains=q) for q in query_list)),
            )
Run Code Online (Sandbox Code Playgroud)

ikl*_*nac 5

通常这只是SQLite的问题,问题在文档链接中有详细描述,也有一个链接可返回原始SQLite网站描述

从django icontains文档

SQLite用户

使用SQLite后端和非ASCII字符串时,请记住有关字符串比较的数据库说明。

有关以下问题的SQLite文档