A
A
Andrey Shubin2017-07-25 15:43:48
SQLite
Andrey Shubin, 2017-07-25 15:43:48

Problem with search, case and cyrillic in Django REST Framework?

The problem is the following: I'm doing a search by the name and category of the organization, the search should be case-insensitive. Everything is ok with Latin, but Cyrillic remains case sensitive.

class CompanyViewSet(viewsets.ReadOnlyModelViewSet):
    """
    Return a list of all the companies with optional search.
    """
    queryset = models.Company.objects\
        .filter(parent=None)\
        .annotate(Count('childs'))\
        .order_by('-rating')
    queryset = serializers.CompanySerializer.setup_eager_loading(queryset)
    serializer_class = serializers.CompanySerializer
    filter_backends = (filters.SearchFilter,)
    search_fields = ('name', 'category__name')

As I understood from the DRF documentation , the default search is case-insensitive.
By default, searches will use case-insensitive partial matches.

Screenshots describing the problem (cafe - Ok, cafe - fail, Cafe - Ok)
2f971285c38b4718ac07e5f281c000a5.pngec236048a41d42d4afd640582c410317.png4129b85e6231434c8b4676d3e784e953.png

Can anyone come across and can suggest a beautiful solution to the problem?
UPD I'm clarifying: the database is now SQLite3, there are suspicions that there will be no such problem on some PostgreSQL, but on my laptop I would still like to develop with the database in a simpler way ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2017-07-25
@idegree

The problem is in SQLite and it is unsolvable without a rebuild.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question