Hrayr Stepanyan
Hrayr Stepanyan

Reputation: 43

Django: icontains case is sensitive for unicode

I'm making a simple search for my blog. I use an armenian language and when I'm searching it's always sensetive for these letters. Here is a part of my code. Thank you in advance.

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)),
            )

Upvotes: 2

Views: 1664

Answers (1)

iklinac
iklinac

Reputation: 15738

This is generaly just problem with SQLite, problem is described in details on documentation link, also there is a link getting back to original SQLite site description

From django icontains documentation

SQLite users

When using the SQLite backend and non-ASCII strings, bear in mind the database note about string comparisons.

SQLite documentation regarding following problem

Upvotes: 6

Related Questions