Error while configuring postgressql for django

一世执手 提交于 2021-02-08 06:40:11

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!