[Answered ]-Django – Use postgres unaccent with django-filters library

1👍

Replying this just in case someone has the same question. Turns out this is way simpler than i thought. By adding unaccent__ before the lookup expression (just like it’s described in the docs), the extension can be used with django-filters. Here’s the example provided in the question:

class BranchesFilter(django_filters.FilterSet):
    name = CharFilter(
        label='Filial',
        label_suffix='',
        field_name='name',
        lookup_expr='unaccent__icontains',
    )
    
    class Meta:
        model = Branches
        fields = '__all__'
👤Zedh

Leave a comment