问题
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
回答1:
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.
来源:https://stackoverflow.com/questions/64712167/error-while-configuring-postgressql-for-django