为Django配置Postgressql时出错 [英] Error while configuring postgressql for django

查看:40
本文介绍了为Django配置Postgressql时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用PostgreSQL在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

推荐答案

我猜你忘了安装

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.

这篇关于为Django配置Postgressql时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆