Answer the question
In order to leave comments, you need to log in
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')
By default, searches will use case-insensitive partial matches.
Answer the question
In order to leave comments, you need to log in
The problem is in SQLite and it is unsolvable without a rebuild.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question