70 words
1 minute
Enabling the fuzzystrmatch extension in PostgreSQL with a Django migration
Anubhav Gain
2024-02-12

Enabling the fuzzystrmatch extension in PostgreSQL with a Django migration#

The PostgreSQL fuzzystrmatch extension enables several functions for fuzzy string matching: soundex(), difference(), levenshtein(), levenshtein_less_equal(), metaphone(), dmetaphone() and dmetaphone_alt().

Enabling them for use with Django turns out to be really easy - it just takes a migration that looks something like this:

from django.contrib.postgres.operations import CreateExtension
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("core", "0089_importrun_sourcelocation"),
]
operations = [
CreateExtension(name="fuzzystrmatch"),
]
Enabling the fuzzystrmatch extension in PostgreSQL with a Django migration
https://mranv.pages.dev/posts/enabling-the-fuzzystrmatch-extension-in-postgresql-with-a-django-migration/
Author
Anubhav Gain
Published at
2024-02-12
License
CC BY-NC-SA 4.0