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

前端 未结 5 1770
挽巷
挽巷 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:35

    I don't believe you'll be able to use the standard Django field-lookups for this unless you store a non-accented version of your text in another column and do the lookup there. You could add a duplicate column with editable=False and override the model's save() method to update that field from the original accented text.

    Python: Remove accents from unicode

    PostgreSQL Wiki: Strip accents from strings, and output in lowercase

提交回复
热议问题