how to have Accent-insensitive filter in django with postgres?

前端 未结 5 1787
挽巷
挽巷 2021-02-04 12:32

Hi I find that on postgres database, we can\'t configure default accent sensivity (on old mail exchanges).

Is there a way to have a _icontains also insensitive to specia

5条回答
  •  难免孤独
    2021-02-04 12:49

    I'm working on an unaccent lookup field for django and postgreSQL. It's on github: https://github.com/marianobianchi/django-accent-free-lookup

    It's working fine for now, but it still need a lot of work. I'm using it and it doesn't show any problems for now.

    The way of using it is to make a new Manager for the model you want to have unaccents searches (look at the example stored at the end of managers.py file at the project).

    The lookups I have already implement are:

    "__aexact"

    "__aiexact"

    "__acontains"

    "__aicontains"

    They are equivalent to the common field lookups that come with django:

    "__exact"

    "__iexact"

    "__contains"

    "__icontains"

    with the difference that they are "accent insensitive" for the most common accented characters.

提交回复
热议问题