Samyak Jain
Samyak Jain

Reputation: 367

Error while configuring postgressql for django

I have implemented full text search in my django app using postgresql. But, when I press the search button, I get an error:

ProgrammingError at /blog/search/
function similarity(character varying, unknown) does not exist
LINE 1: SELECT COUNT(*) FROM (SELECT SIMILARITY("blog_post"."title",...
                                     ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

I don't know where the error is, so if you need any files, I will edit this question. Please help me

Upvotes: 1

Views: 587

Answers (2)

Diego Barbosa
Diego Barbosa

Reputation: 1

Are you working with 'Django by Example' book? Did you put the real DB at 'psql blog' command ? I get the same error, so I tryed 'psql blogDB'... the real name that I gave. That work fine!

Upvotes: 0

Lord Elrond
Lord Elrond

Reputation: 15992

I'm guessing you forgot to install the pg_trgm extension. To install it using django, create a file called pg_trgm.py inside of your app's migrations directory:

from django.db import migrations

class Migration(migrations.Migration):
    dependencies = [
        ('myapp', <last migration filename here>),
    ]
    operations = [
        migrations.RunSQL('CREATE EXTENSION IF NOT EXISTS pg_trgm'),
    ]

Remember to replace <last migration filename here> with the filename of your most recent migration.

Upvotes: 4

Related Questions