The migration file must be done manually and applied.
First create an empty migration:
./manage.py makemigrations myapp --empty
Then open the file and add UnaccentExtension to operations :
from django.contrib.postgres.operations import UnaccentExtension class Migration(migrations.Migration): dependencies = [ (<snip>) ] operations = [ UnaccentExtension() ]
Now apply the migration using ./manage.py migrate .
If at this last stage you get the following error:
django.db.utils.ProgrammingError: permission denied to create extension "unaccent" HINT: Must be superuser to create this extension.
... then temporarily grant superuser rights to your user by doing postgres# ALTER ROLE <user_name> SUPERUSER; and his NOSUPERUSER . pgAdminIII can do this too.
Now enjoy impeccable functionality using Django:
>>> Person.objects.filter(first_name__unaccent=u"Helène") [<Person: Michels Hélène>]
source share